<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2854</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="2854"></A><H4>2854.
  
Storage duration of exception objects
</H4>
<B>Section: </B>14.2&#160; [<A href="https://wg21.link/except.throw">except.throw</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jiang An
 &#160;&#160;&#160;

 <B>Date: </B>2024-01-22<BR>


<P>[Accepted as a DR at the March, 2024 meeting.]</P>

<P>(From submission
<A HREF="https://github.com/cplusplus/CWG/issues/492">#492</A>.)</P>

<P>According to 14.2 [<A href="https://wg21.link/except.throw#3">except.throw</A>] paragraph 3, the exception
object is a temporary object.  But none of the possible storage
durations of temporary objects matches the behavior of exception
objects.</P>

<P><B>Proposed resolution (approved by CWG 2024-02-16):</B></P>

<OL>
<LI>
<P>Change in 6.8.7 [<A href="https://wg21.link/class.temporary#1">class.temporary</A>] paragraph 1 as follows:</P>

<BLOCKQUOTE>

Temporary objects are created
<UL>
<LI>when a prvalue is converted to an xvalue (7.3.5 [<A href="https://wg21.link/conv.rval">conv.rval</A>])<DEL>,</DEL> <INS>and</INS>
</LI>
<LI>when needed by the implementation to pass or return an object of
trivially copyable type (see below)<DEL>, and</DEL><INS>.</INS>
</LI>
<LI class="del">when throwing an exception
(14.2 [<A href="https://wg21.link/except.throw">except.throw</A>]).  [<I>Note 1:</I> The lifetime of
exception objects is described in
14.2 [<A href="https://wg21.link/except.throw">except.throw</A>]. &#8212;<I>end note</I>]</LI>
</UL>
...

</BLOCKQUOTE>
</LI>

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

<BLOCKQUOTE>

Throwing an exception initializes <DEL>a temporary</DEL> <INS>an</INS>
object <INS>with dynamic storage duration</INS>, called the exception
object. If the type of the exception object would be an incomplete
type (6.9.1 [<A href="https://wg21.link/basic.types.general">basic.types.general</A>]), an abstract class type
(11.7.4 [<A href="https://wg21.link/class.abstract">class.abstract</A>]), or a pointer to an incomplete type
other than cv void (6.9.4 [<A href="https://wg21.link/basic.compound">basic.compound</A>]) the program is
ill-formed.

</BLOCKQUOTE>
</LI>
</OL>

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