<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 326</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="326"></A><H4>326.
  
Wording for definition of trivial constructor
</H4>
<B>Section: </B>11.4.5&#160; [<A href="https://wg21.link/class.ctor">class.ctor</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>James Kanze
 &#160;&#160;&#160;

 <B>Date: </B>9 Dec 2001<BR>


<P>[Voted into WP at October 2003 meeting.]</P>



<P>In 11.4.5 [<A href="https://wg21.link/class.ctor#5">class.ctor</A>] paragraph 5, the standard says
"A constructor is trivial if [...]", and goes on to define a trivial
default constructor.  Taken literally, this would mean that a copy
constructor can't be trivial (contrary to 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#6">class.copy.ctor</A>] paragraph 6).  I suggest changing this to "A default
constructor is trivial if [...]".  (I think the change is purely
editorial.)</P>

<P><B>Proposed Resolution (revised October 2002):</B></P>

<P>Change 11.4.5 [<A href="https://wg21.link/class.ctor#5">class.ctor</A>] paragraph 5-6 as follows: </P>
<BLOCKQUOTE>
<P>
A <I>default</I> constructor for a class <TT>X</TT>
is a constructor of class <TT>X</TT>
that can be called without an argument.
If there is no
<DEL><I>user-declared</I></DEL>
<INS>user-declared</INS>
constructor for class <TT>X</TT>,
a default constructor is implicitly declared.
An
<DEL><I>implicitly-declared</I></DEL>
<INS>implicitly-declared</INS>
default constructor
is an <TT>inline public</TT> member of its class.
A
<INS>default</INS>
constructor is <I>trivial</I>
if it is <DEL>an</DEL> implicitly-declared <DEL>default constructor</DEL>
and if:
<UL>
<LI>
its class has no virtual functions (11.7.3 [<A href="https://wg21.link/class.virtual">class.virtual</A>])
and no virtual base classes (11.7.2 [<A href="https://wg21.link/class.mi">class.mi</A>]), and
</LI>
<LI>
all the direct base classes of its class
have trivial
<INS>default</INS>
constructors, and
</LI>
<LI>
for all the nonstatic data members of its class
that are of class type (or array thereof),
each such class has a trivial
<INS>default</INS>
constructor.
</LI>
</UL>
</P>
<P>
Otherwise, the
<INS>default</INS>
constructor is non-trivial.
</P>
</BLOCKQUOTE>
<P>
Change 11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>] paragraphs 3-4 as follows (the main
changes are removing italics):</P>
<BLOCKQUOTE>
<P>If a class has no
<DEL><I>user-declared</I></DEL>
<INS>user-declared</INS>
destructor, a destructor  is  declared
implicitly.   An
<DEL><I>implicitly-declared</I></DEL>
<INS>implicitly-declared</INS>
destructor  is an <TT>inline public</TT>
member of its class.  A destructor is <I>trivial</I> if it is <DEL>an</DEL>
implicitly-declared <DEL>destructor</DEL> and if:
<UL>
<LI>
all of the direct base classes of its class have trivial destructors and
</LI>
<LI>
for all of the non-static data members of  its  class  that  are  of
class  type  (or  array  thereof),  each  such  class  has a trivial
destructor.
</LI>
</UL>
</P>
<P>Otherwise, the destructor is
<DEL><I>non-trivial</I></DEL>
<INS>non-trivial</INS>.
</P>
</BLOCKQUOTE>

<P>
In 11.5 [<A href="https://wg21.link/class.union#1">class.union</A>] paragraph 1, change "trivial constructor"
to "trivial default constructor".
</P>

<P>
In 6.8.7 [<A href="https://wg21.link/class.temporary#3">class.temporary</A>] paragraph 3, add to the reference to
11.4.5 [<A href="https://wg21.link/class.ctor">class.ctor</A>] a second reference, to
11.4.5.3 [<A href="https://wg21.link/class.copy.ctor">class.copy.ctor</A>].</P>

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