Informs the compiler that the function does not return. The compiler can then perform optimizations by removing code that is never reached.
Note
This attribute has the GNU-style equivalent __attribute__((noreturn)).
If the function reaches an explicit or implicit return,
__declspec(noreturn) is ignored and the compiler generates a
warning:
Warning: #1461-D: function declared with "noreturn" does return
Usage
Use this attribute to reduce the cost of calling a function that never returns, such as
exit().
Best practice is to always terminate non-returning functions with
while(1);.
Example
__declspec(noreturn) void overflow(void); // called on overflow
int negate(int x)
{
if (x == 0x80000000) overflow();
return -x;
}
void overflow(void)
{
__asm {
SVC 0x123; // hypothetical exception-throwing system service
}
while (1);
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.