Replies: 1 comment 1 reply
-
Yes I think we should add assertions. I don't expect string functions to be super performance-sensitive, and in theory we can eliminate all the overhead of all assertions by compiling code in release mode. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Some C library functions don't allow their pointer arguments to be
NULL
(e.g.strtok
s delimiter argument). In case ofglibc
, they respond toNULL
by crashing with a segfault. For debugging purposes, and to make it easier to reason about segfaults, it would be beneficial if they calledassert(x != NULL)
instead.The downside of adding assertions to frequently called functions might be that the performance is slightly worse. At the time of writing this, there are a few assertions found in
/include/uvm
already.In general, should assertions be added to library functions that have certain constraints like requiring pointers to not be
NULL
?Beta Was this translation helpful? Give feedback.
All reactions