Bruno Haible wrote:
What is the semantic difference between _Noreturn and
__attribute_noreturn__?
__attribute__ ((__noreturn__)), which the latter expands to, also works with
function pointers, whereas _Noreturn does not. The distinction can matter when a
function's address is assigned to a function pointer. Clang checks for
__attribute__ ((__noreturn__)) compatibility when assigning function pointers;
GCC does not, which can lead to weird results. For example:
_Noreturn void nr (void) { for (;;); }
__attribute__ ((__noreturn__)) void anr (void) { for (;;); }
/* Valid. */
void (*a) (void) = nr;
void (*b) (void) = anr;
__attribute__ ((__noreturn__)) void (*c) (void) = anr;
/* Invalid, as _Noreturn applies only to function definitions. */
_Noreturn void (*d) (void) = nr;
_Noreturn void (*e) (void) = anr;
/* Allowed by GCC, but weirdly disallowed by clang because f is not declared
with
__attribute__ ((__noreturn__)). */
__attribute__ ((__noreturn__)) void (*f) (void) = nr;
GCC does a better job in this area, and it's not clear that it's worth catering
to clang's idiosyncracies here.