<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 592</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="592"></A><H4>592.
  
Exceptions during construction of local static objects
</H4>
<B>Section: </B>14.3&#160; [<A href="https://wg21.link/except.ctor">except.ctor</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Alisdair Meredith
 &#160;&#160;&#160;

 <B>Date: </B>30 August 2006<BR>


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

<P>According to 14.3 [<A href="https://wg21.link/except.ctor#2">except.ctor</A>] paragraph 2,</P>

<BLOCKQUOTE>

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 [<A href="https://wg21.link/class.base.init">class.base.init</A>]) 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.

</BLOCKQUOTE>

<P>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?</P>

<P><B>Proposed resolution (October, 2006):</B></P>

<P>Change 14.3 [<A href="https://wg21.link/except.ctor#2">except.ctor</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

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 [<A href="https://wg21.link/class.base.init">class.base.init</A>]) 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. <DEL>Should a constructor for an
element of an automatic array throw an exception, only the constructed
elements of that array will be destroyed.</DEL> If the object or array was
allocated in a <I>new-expression</I>, the matching deallocation
function (6.8.6.5.3 [<A href="https://wg21.link/basic.stc.dynamic.deallocation">basic.stc.dynamic.deallocation</A>], 7.6.2.8 [<A href="https://wg21.link/expr.new">expr.new</A>], 11.4.11 [<A href="https://wg21.link/class.free">class.free</A>]), if any, is called to
free the storage occupied by the object.

</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
