Title
Lifetime of exception::what() return unspecified
Status
tc1
Section
[type.info]
Submitter
AFNOR

Created on 1998-10-07.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

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

Date: 2010-10-21.18:28:33

Proposed resolution:

Add to [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.

Date: 1998-10-07.00:00:00

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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg626
2010-10-21 18:28:33adminsetmessages: + msg625
1998-10-07 00:00:00admincreate