9.24 __declspec(noreturn)

The __declspec(noreturn) attribute asserts that a function never returns.


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).


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.


The return address is not preserved when calling the noreturn function. This limits the ability of a debugger to display the call stack.


__declspec(noreturn) void overflow(void); // never return on overflow
int negate(int x) 
    if (x == 0x80000000) overflow();
    return -x;
Related reference
9.41 __attribute__((noreturn)) function attribute
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.