<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1218</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="1218"></A><H4>1218.
  
What is the &#8220;currently-handled exception&#8221; in a multi-threaded program?
</H4>
<B>Section: </B>14.4&#160; [<A href="https://wg21.link/except.handle">except.handle</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>2010-11-12<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#CA5">N3092 comment
  CA&#160;5<BR></A>

<P>14.4 [<A href="https://wg21.link/except.handle#8">except.handle</A>] paragraph 8 defines the &#8220;currently
handled exception&#8221; as</P>

<BLOCKQUOTE>

The exception with the most recently activated handler that is still active

</BLOCKQUOTE>

<P>This definition ignores the possibility that an exception might be
thrown and caught in another thread during the execution of a handler.
Since <TT>throw;</TT> rethrows the &#8220;currently handled
exception,&#8221; one might conclude that it would be the other
thread's exception that would be rethrown instead of the one that
activated that handler.</P>

<P><B>Proposed resolution (January, 2011):</B></P>

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

<BLOCKQUOTE>

Exception handling provides a way of transferring control and
information from a point in the execution of a <DEL>program</DEL>
<INS>thread</INS> to an exception handler associated with a point
previously passed by the execution...

</BLOCKQUOTE>

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

<BLOCKQUOTE>

...The implementation may then deallocate the memory for the exception
object; any such deallocation is done in an unspecified way. <INS>[<I>Note:</I>
An exception thrown by a <I>throw-expression</I> does not propagate to other
threads unless caught, stored, and rethrown using appropriate library
functions; see 17.9.7 [<A href="https://wg21.link/propagation">propagation</A>] and 32.10 [<A href="https://wg21.link/futures">futures</A>].
&#8212;<I>end note</I>]</INS>

</BLOCKQUOTE>

<LI><P>Change 14.4 [<A href="https://wg21.link/except.handle#6">except.handle</A>] paragraph 6 as follows:</P></LI>

If no match is found among the handlers for a try block, the search
for a matching handler continues in a dynamically surrounding try
block <INS>of the same thread</INS>.

</OL>



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