On this page
_Noreturn
Prev: _Static_assert | Up: builtins | Next: void
Rel: exit(), abort()
Ref: cppreference — _Noreturn
Tags: #public #prog #c #builtins #tier/specialized
Availability
Built-in (Function Specifier (C11; [[noreturn]] in C23)) — requires no #include header.
Syntax & Overview
_Noreturn void fatal(const char *msg);
Informs the compiler that a function never returns to its caller (e.g., calls exit() or abort()).
Notes & Pitfalls
- Marks functions that never return to the caller (e.g.,
exit,abort, fatal panic helpers) so the compiler omits dead-code warnings. - Returning from a
_Noreturnfunction is UB (C23 prefers[[noreturn]]).
Example
#include <stdlib.h>
_Noreturn void die(int code) {
exit(code);
}
Linked from
Related notes
- tuts/c/builtins/_Static_assert Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/void Linked here; links to this page; shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins Linked here; links to this page; shared tags: #builtins, #c, #prog
- tuts/c/stdlib/stdlib/abort Linked here; shared tags: #c, #prog, #tier
- tuts/c/stdlib/stdlib/exit Linked here; shared tags: #c, #prog, #tier
- tuts/c/builtins/__FILE__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__func__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__LINE__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/__STDC_VERSION__ shared tags: #builtins, #c, #prog, #tier
- tuts/c/builtins/_Alignof shared tags: #builtins, #c, #prog, #tier