Title
function-try-blocks for destructors
Status
c++11
Section
14.5 [except.spec]
Submitter
GB

Created on 2010-08-03.00:00:00 last changed 130 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting.]

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

Change Clause 14 [except] paragraph 4 as follows:

A function-try-block associates a handler-seq with the ctor-initializer, if present, and the compound-statement. An exception thrown during the execution of the initializer expressions in the ctor-initializer or during the execution of the compound-statement or, for constructors and destructors, during the initialization or destruction, respectively, of the class's subobjects, transfers control to a handler in a function-try-block in the same way as an exception thrown during the execution of a try-block transfers control to other handlers.
Date: 2010-10-15.00:00:00

Additional note (October, 2010):

There is a related problem with this wording: it covers only “the execution of the initializer expressions in the ctor-initializer,” when it should also cover execution of base and member constructors, regardless of whether they have initializer expressions in the ctor-initializer or not.

The issue has been moved back to "review" status to allow consideration of amending the proposed resolution to something like

...during the execution of the compound-statement or, if the function is a constructor or destructor, during the initialization or destruction of the class's subobjects, transfers control...
Date: 2010-08-15.00:00:00

Proposed resolution (August, 2010):

Change Clause 14 [except] paragraph 4 as follows:

...An exception thrown during the execution of the initializer expressions in the ctor-initializer or during the execution of the compound-statement, or — in the case of a destructor — during the destruction of a subobject, transfers control to a handler in a function-try-block in the same way as an exception thrown during the execution of a try-block transfers control to other handlers. [Example:...
Date: 2010-08-03.00:00:00
N3092 comment GB 46

It is not entirely clear that a function-try-block on a destructor will catch exceptions from a base or member destructor; whether such exceptions might be swallowed with a simple return statement rather than being rethrown; and whether such a clause might be entered multiple times if multiple bases/members throw, or if that is an automatic terminate call.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3408
2011-04-10 00:00:00adminsetstatus: ready -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3063
2010-11-29 00:00:00adminsetstatus: review -> ready
2010-10-18 00:00:00adminsetmessages: + msg3002
2010-10-18 00:00:00adminsetstatus: ready -> review
2010-08-23 00:00:00adminsetmessages: + msg2817
2010-08-03 00:00:00admincreate