2 ms·
No thanks, I'm going to keep calling abort (ANSI C, 1989) to indicate "control stops here": Code after an abort() call is unreachable. (Or after any function a
by kazinator 4y ago
No thanks, I'm going to keep calling abort (ANSI C, 1989) to indicate "control stops here":
Code after an abort() call is unreachable. (Or after any function attributed noreturn).
GCC and Clang know this, and do things accordingly.
For instance, I've seen GCC emit code which assumes that ptr is not null after ASSERT(ptr != NULL), because the custom ASSERT macro called an __attribute__((noreturn)) function in the null case.
abort() has defined behavior; it terminates the program abnormally, as if by raising the SIGABRT signal.
Your own function attributed __noreturn__ can have whatever behavior you want it to have. The one in the ASSERT macro I alluded to above calculates and prints a backtrace and other useful information.