The __declspec(noreturn) attribute asserts
that a function never returns.
Note
This attribute has the function equivalent __attribute((noreturn)).
However, __attribute((noreturn)) and __declspec(noreturn) differ
in that when compiling a function definition, if the function reaches
an explicit or implicit return, __attribute((noreturn)) is ignored
and the compiler generates a warning. This does not apply to __declspec(noreturn).
Usage
Use this attribute to reduce the cost of calling a function
that never returns, such as exit(). If a noreturn function
returns to its caller, the behavior is undefined.
Restrictions
The return address is not preserved when calling the noreturn function.
This limits the ability of a debugger to display the call stack.
Example
__declspec(noreturn) void overflow(void); // never return on overflow
int negate(int x)
{
if (x == 0x80000000) overflow();
return -x;
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.