If my understanding is correct, since crash() stops the program via __builtin_trap(), adding the noreturn attribute would allow the compiler to optimize in certain cases. Consider the case of an assert() on a pointer. Since assert() uses crash() if the pointer is NULL, this lets the compiler correctly discern that the pointer in any code after the assert will in fact not be null.
If my understanding is correct, since
crash()
stops the program via__builtin_trap()
, adding thenoreturn
attribute would allow the compiler to optimize in certain cases. Consider the case of anassert()
on a pointer. Sinceassert()
usescrash()
if the pointer isNULL
, this lets the compiler correctly discern that the pointer in any code after the assert will in fact not be null.