108. Lifetime of exception::what() return unspecified

Section: 17.7.3 [type.info] Status: TC1 Submitter: AFNOR Opened: 1998-10-07 Last modified: 2016-01-28 10:19:27 UTC

Priority: Not Prioritized

View all other issues in [type.info].

View all issues with TC1 status.


In 18.6.1, paragraphs 8-9, the lifetime of the return value of exception::what() is left unspecified. This issue has implications with exception safety of exception handling: some exceptions should not throw bad_alloc.

Proposed resolution:

Add to 17.7.3 [type.info] paragraph 9 (exception::what notes clause) the sentence:

The return value remains valid until the exception object from which it is obtained is destroyed or a non-const member function of the exception object is called.


If an exception object has non-const members, they may be used to set internal state that should affect the contents of the string returned by what().