C1X (C11), the successor of C99, is now designed, among its changes there is 
_Noreturn, this is what the latest free draft says about it:

A function declared with a _Noreturn function specifier shall not return to its 
caller.
The implementation should produce a diagnostic message for a function declared 
with a _Noreturn function specifier that appears to be capable of returning to 
its caller.


_Noreturn void f () {
    abort(); // ok
}
_Noreturn void g (int i) { // causes undefined behavior if i<=0
    if (i > 0) abort();
}



#include <setjmp.h>
_Noreturn void longjmp(jmp_buf env, int val);


#include <stdlib.h>
_Noreturn void abort(void);


#include <stdlib.h>
_Noreturn void exit(int status);


#include <stdlib.h>
_Noreturn void _Exit(int status);


#include <stdlib.h>
_Noreturn void quick_exit(int status);

GNU C has a noreturn attribute since a lot of time. I don't fully understand 
why such attribute is so useful in C programs, but is something like a 
@noreturn function attribute useful in D too? Maybe to implement a better halt 
assert(0)?

Bye,
bearophile

Reply via email to