This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

1066. Use [[noreturn]] attribute in the library

Section: 17 [support] Status: C++11 Submitter: Howard Hinnant Opened: 2009-03-15 Last modified: 2021-06-06

Priority: Not Prioritized

View all issues with C++11 status.

Discussion:

Addresses UK 189 and JP 27 [CD1]

The addition of the [[noreturn]] attribute to the language will be an important aid for static analysis tools.

The following functions should be declared in C++ with the [[noreturn]] attribute: abort exit quick_exit terminate unexpected rethrow_exception throw_with_nested.

[ Summit: ]

Agreed.

[ Batavia (2009-05): ]

We agree with the proposed resolution. Move to Tentatively Ready.

Proposed resolution:

Change 17.5 [support.start.term] p3:

-2- ...

void abort [[noreturn]] (void)

-3- ...

-6- ...

void exit [[noreturn]] (int status)

-7- ...

-11- ...

void quick_exit [[noreturn]] (int status)

-12- ...

Change the <exception> synopsis in 17.9 [support.exception]:

void unexpected [[noreturn]] ();
...
void terminate [[noreturn]] ();
...
void rethrow_exception [[noreturn]] (exception_ptr p);
...
template <class T> void throw_with_nested [[noreturn]] (T&& t); // [[noreturn]]

Change 99 [unexpected]:

void unexpected [[noreturn]] ();

Change 17.9.5.4 [terminate]:

void terminate [[noreturn]] ();

Change 17.9.7 [propagation]:

void rethrow_exception [[noreturn]] (exception_ptr p);

In the synopsis of 17.9.8 [except.nested] and the definition area change:

template <class T> void throw_with_nested [[noreturn]] (T&& t); // [[noreturn]]