<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1167</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="1167"></A><H4>1167.
  
<I>function-try-block</I>s for destructors
</H4>
<B>Section: </B>14.5&#160; [<A href="https://wg21.link/except.spec">except.spec</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++11
 &#160;&#160;&#160;

 <B>Submitter: </B>GB
 &#160;&#160;&#160;

 <B>Date: </B>2010-08-03<BR><BR>


<P>[Voted into the WP at the March, 2011 meeting.]</P>

<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3296.html#GB46">N3092 comment
  GB&#160;46<BR></A>

<P>It is not entirely clear that a <I>function-try-block</I>
on a destructor will catch exceptions from a base or member
destructor; whether such exceptions might be swallowed with
a simple <TT>return</TT> 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.</P>

<P><B>Proposed resolution (August, 2010):</B></P>

<P>Change Clause 14 [<A href="https://wg21.link/except#4">except</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

...An exception thrown during the execution of the
initializer expressions in the <I>ctor-initializer</I> or
during the execution of the <I>compound-statement</I><INS>,
or &#8212; in the case of a destructor &#8212; during the
destruction of a subobject,</INS> transfers control to a
handler in a <I>function-try-block</I> in the same way as an
exception thrown during the execution of a <I>try-block</I>
transfers control to other handlers. [<I>Example:</I>...

</BLOCKQUOTE>

<P><B>Additional note (October, 2010):</B></P>



<P>There is a related problem with this wording: it covers only
&#8220;the execution of the initializer expressions in the
<I>ctor-initializer</I>,&#8221; when it should also cover execution
of base and member constructors, regardless of whether they have
initializer expressions in the <I>ctor-initializer</I> or not.</P>

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

<BLOCKQUOTE>

...during the execution of the <I>compound-statement</I> or, if the
function is a constructor or destructor, during the initialization
or destruction of the class's subobjects, transfers control...

</BLOCKQUOTE>

<P><B>Proposed resolution (November, 2010):</B></P>

<P>Change Clause 14 [<A href="https://wg21.link/except#4">except</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

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

</BLOCKQUOTE>

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