Title
Destruction of exception objects
Status
cd2
Section
14.2 [except.throw]
Submitter
UK

Created on 2009-03-03.00:00:00 last changed 178 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-09-15.00:00:00

Proposed resolution (September, 2009):

Change 14.2 [except.throw] paragraph 4 as follows:

The memory for the temporary copy of the exception being thrown exception object is allocated in an unspecified way, except as noted in 6.7.5.5.2 [basic.stc.dynamic.allocation]. The temporary persists as long as there is a handler being executed for that exception. In particular, if If a handler exits by executing a throw; statement, that passes control rethrowing, control is passed to another handler for the same exception, so the temporary remains. The exception object is destroyed after either When the last remaining active handler for the exception exits by any means other than throw; rethrowing, or the last object of type std::exception_ptr (17.9.7 [propagation]) that refers to the exception object is destroyed, whichever is later. In the former case, the destruction occurs when the handler exits, immediately after the destruction of the object declared in the exception-declaration in the handler, if any. In the latter case, the destruction occurs before the destructor of std::exception_ptr returns. the temporary object is destroyed and the The implementation may then deallocate the memory for the temporary exception object; any such deallocation is done in an unspecified way. The destruction occurs immediately after the destruction of the object declared in the exception-declaration in the handler.
Date: 2009-03-03.00:00:00
N2800 comment UKĀ 130

14.2 [except.throw] paragraph 4 says,

When the last remaining active handler for the exception exits by any means other than throw; the temporary object is destroyed and the implementation may deallocate the memory for the temporary object...

With std::current_exception() (17.9.7 [propagation] paragraph 7) , it might be possible to refer to the exception object after its last handler exits (if the exception object is not copied). The text needs to be updated to allow for that possibility.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2746
2010-03-29 00:00:00adminsetstatus: ready -> cd2
2009-11-08 00:00:00adminsetstatus: review -> ready
2009-09-29 00:00:00adminsetmessages: + msg2308
2009-09-29 00:00:00adminsetstatus: drafting -> review
2009-08-03 00:00:00adminsetstatus: open -> drafting
2009-03-03 00:00:00admincreate