4.2.4. __declspec(noreturn)

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

Note

This __declspec attribute has the function attribute equivalent __attribute__(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;
}

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential