Title
Return object destruction from throwing postcondition evaluation
Status
tentatively ready
Section
14.3 [except.ctor]
Submitter
Joshua Berne

Created on 2026-08-25.00:00:00 last changed 5 days ago

Messages

Date: 2026-10-16.19:06:14

Proposed resolution (approved by CWG 2026-10-16):

Change in 14.3 [except.ctor] paragraph 2 as follows:

Each object with automatic storage duration is destroyed if it has been constructed, but not yet destroyed, since the try block was entered. If an exception is thrown during the destruction of temporaries or local variables for a return statement (8.8.4 [stmt.return]), or from the evaluation of postcondition assertions of the enclosing function (7.6.1.3 [expr.call]), the destructor for the returned object (if any) is also invoked. The objects are destroyed in the reverse order of the completion of their construction. [ Example: ... ]
Date: 2026-08-25.00:00:00

(From submission #988.)

The return object is created while evaluating a return statement. It needs to be destroyed when a later evaluation in that same function exits via an exception, i.e. destruction of temporaries or local variables (already covered). The consideration of an exception thrown from a postcondition evaluation is missing.

History
Date User Action Args
2026-10-16 19:06:14adminsetstatus: open -> tentatively ready
2026-10-11 20:43:03adminsetmessages: + msg8707
2026-08-25 00:00:00admincreate