Title
Exceptions during construction of local static objects
Status
cd1
Section
14.3 [except.ctor]
Submitter
Alisdair Meredith

Created on 2006-08-30.00:00:00 last changed 161 months ago

Messages

Date: 2008-09-15.00:00:00

[Voted into the WP at the September, 2008 meeting (resolution in paper N2757).]

Date: 2006-10-15.00:00:00

Proposed resolution (October, 2006):

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

An object that is partially constructed or partially destroyed will have destructors executed for all of its fully constructed subobjects, that is, for subobjects for which the principal constructor (11.9.3 [class.base.init]) has completed execution and the destructor has not yet begun execution. Similarly, if the non-delegating constructor for an object has completed execution and a delegating constructor for that object exits with an exception, the object's destructor will be invoked. Should a constructor for an element of an automatic array throw an exception, only the constructed elements of that array will be destroyed. If the object or array was allocated in a new-expression, the matching deallocation function (6.7.5.5.3 [basic.stc.dynamic.deallocation], 7.6.2.8 [expr.new], 11.11 [class.free]), if any, is called to free the storage occupied by the object.
Date: 2006-08-30.00:00:00

According to 14.3 [except.ctor] paragraph 2,

An object that is partially constructed or partially destroyed will have destructors executed for all of its fully constructed subobjects, that is, for subobjects for which the principal constructor (11.9.3 [class.base.init]) has completed execution and the destructor has not yet begun execution. Similarly, if the non-delegating constructor for an object has completed execution and a delegating constructor for that object exits with an exception, the object's destructor will be invoked. Should a constructor for an element of an automatic array throw an exception, only the constructed elements of that array will be destroyed.

The requirement for destruction of array elements explicitly applies only to automatic arrays, and one might conclude from the context that only automatic class objects are in view as well, although that is not explicitly stated. What about local static arrays and class objects? Are they intended also to be subject to the requirement that fully-constructed subobjects are to be destroyed?

History
Date User Action Args
2008-10-05 00:00:00adminsetmessages: + msg1832
2008-10-05 00:00:00adminsetstatus: review -> cd1
2006-11-05 00:00:00adminsetmessages: + msg1411
2006-11-05 00:00:00adminsetstatus: open -> review
2006-08-30 00:00:00admincreate