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

Section: 21 [language.support] Status: C++11 Submitter: Howard Hinnant Opened: 2009-03-15 Last modified: 2016-02-10

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 21.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 21.8 [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 21.8.4.4 [terminate]:

void terminate [[noreturn]] ();

Change 21.8.6 [propagation]:

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

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

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