323d4b6f68
These functions should print assertion violation messages and then call abort(). They do really not return control flow afterwards. Consider the declaration of the similar __assert_fail from glibc: extern void __assert_fail (const char *__assertion, const char *__file, unsigned int __line, const char *__function) __THROW __attribute__ ((__noreturn__)); Bionic has __noreturn defined in sys/cdefs.h to be that GNU noreturn attribute. This patch has a practical value. Consider the following function: void check(void* ptr) { assert(ptr != NULL); } Without this patch applied, gcc (and presumably clang) shows even in debug mode: warning: unused parameter 'ptr' [-Wunused-parameter] In release mode, NDEBUG is defined and assert() becomes a no-op, as one should expect. Thus, the warning is shown correctly then. Another code sample: float array[2]; int i = 3; ... assert(i < 2); array[i] = 0; gcc says, warning: array subscript is below array bounds [-Warray-bounds] In other words, without noreturn attribute, assertions do not allow a compiler's static analyzer to properly understand the preconditions. Change-Id: I3be92e99787c528899cf243ed448c4730c00c45b Signed-off-by: Vadim Markovtsev <gmarkhor@gmail.com>