You copied the Doc URL to your clipboard.


Informs the compiler that the function does not return. The compiler can then perform optimizations by removing code that is never reached.


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


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


__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);
Was this page helpful? Yes No