<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2424</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="2424"></A><H4>2424.
  
<TT>constexpr</TT> initialization requirements for variant members
</H4>
<B>Section: </B>9.2.6&#160; [<A href="https://wg21.link/dcl.constexpr">dcl.constexpr</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

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


<P>[Adopted as a DR at the November, 2019 meeting.]</P>



<P>Paper <A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1331r2.pdf">P1331R2</A>
removed the requirement that a constexpr constructor
initialize every non-variant non-static data member, but it
left untouched the corresponding requirements for variant
members.  That is, the modified text in 9.2.6 [<A href="https://wg21.link/dcl.constexpr#4">dcl.constexpr</A>] paragraph 4
still contains:</P>

<BLOCKQUOTE>

<P>The definition of a constexpr constructor
whose <I>function-body</I> is not <TT>= delete</TT> shall
additionally satisfy the following requirements:</P>

<UL>
<LI><P>if the class is a union having variant members
(11.5 [<A href="https://wg21.link/class.union">class.union</A>]), exactly one of them shall be
initialized;</P></LI>

<LI><P>if the class is a union-like class, but is not a
union, for each of its anonymous union members having
variant members, exactly one of them shall be
initialized;</P></LI>

</UL>

</BLOCKQUOTE>

<P>Presumably this was an oversight and these two bullets
should be changed from &#8220;exactly&#8221; to &#8220;at
most&#8221; or something similar.</P>

<P><B>Proposed resolution (September, 2019):</B></P>

<P>Delete the indcated text from 9.2.6 [<A href="https://wg21.link/dcl.constexpr#4">dcl.constexpr</A>] paragraph 4:</P>

<BLOCKQUOTE>

<P>The definition of a constexpr constructor
whose <I>function-body</I> is not <TT>= delete</TT> shall
additionally satisfy the following requirements:</P>

<UL>
<LI><P><DEL>if the class is a union having variant members
(11.5 [<A href="https://wg21.link/class.union">class.union</A>]), exactly one of them shall be
initialized;</DEL></P></LI>

<LI><P>
<DEL>if the class is a union-like class, but is not a union, for
each of its anonymous union members having variant members,
exactly one of them shall be initialized;</DEL>
</P></LI>

<LI><P>for a non-delegating constructor, every constructor selected
to initialize non-static data members and base class
subobjects shall be a constexpr constructor;</P></LI>

<LI><P>for a delegating constructor, the target constructor shall
be a constexpr constructor.</P></LI>

</UL>

</BLOCKQUOTE>

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