<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1191</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="1191"></A><H4>1191.
  
Deleted subobject destructors and implicitly-defined constructors
</H4>
<B>Section: </B>11.4.5&#160; [<A href="https://wg21.link/class.ctor">class.ctor</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2010-09-02<BR>


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



<P>Consider the following example:</P>

<PRE>
    struct A {
       A();
       ~A() = delete;
    };

    struct B: A { };
    B* b = new B;
</PRE>

<P>Under the current rules, <TT>B()</TT> is not deleted, but is
ill-formed because it calls the deleted <TT>~A::A()</TT> if it exits
via an exception after the completion of the construction of
<TT>A</TT>. A deleted subobject destructor should be added to the list
of reasons for implicit deletion in 11.4.5 [<A href="https://wg21.link/class.ctor">class.ctor</A>] and
11.4.5.3 [<A href="https://wg21.link/class.copy.ctor">class.copy.ctor</A>].</P>

<P><B>Notes from the November, 2010 meeting:</B></P>

<P>The CWG agreed that a change was needed, but only if one or more
base and/or member constructors are non-trivial.</P>

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

<OL>
<LI><P>Add a new bullet to 11.4.5 [<A href="https://wg21.link/class.ctor#5">class.ctor</A>] paragraph 5 as
follows:</P></LI>

<BLOCKQUOTE>

<P>...A defaulted default constructor for class <TT>X</TT> is defined
as deleted if:</P>

<UL>
<LI><P>...</P></LI>

<LI><P>
<TT>X</TT> is a non-union class and all members of any
anonymous union member are of const-qualified type (or array thereof),
<DEL>or</DEL>
</P></LI>

<LI><P>any direct or virtual base class, or non-static data member
with no <I>brace-or-equal-initializer</I>, has class type <TT>M</TT>
(or array thereof) and either <TT>M</TT> has no default constructor or
overload resolution (12.2 [<A href="https://wg21.link/over.match">over.match</A>]) as applied to
<TT>M</TT>'s default constructor results in an ambiguity or in a
function that is deleted or inaccessible from the defaulted default
constructor<DEL>.</DEL><INS>, or</INS>
</P></LI>

<LI><P><INS>any direct or virtual base class or non-static data member
has a type with a destructor that is deleted or inaccessible from the
defaulted default constructor.</INS></P></LI>

</UL>

</BLOCKQUOTE>

<LI><P>Add a new bullet to 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#12">class.copy.ctor</A>] paragraph 12 as
follows:</P></LI>

<BLOCKQUOTE>

<P>...A defaulted copy/move constructor for a class <TT>X</TT> is
defined as deleted (9.6.3 [<A href="https://wg21.link/dcl.fct.def.delete">dcl.fct.def.delete</A>]) if X has:</P>

<UL>
<LI><P>a variant member with a non-trivial corresponding
constructor and <TT>X</TT> is a union-like class,</P></LI>

<LI><P>a non-static data member of class type <TT>M</TT> (or array
thereof) that cannot be copied/moved because overload resolution
(12.2 [<A href="https://wg21.link/over.match">over.match</A>]), as applied to <TT>M</TT>'s corresponding
constructor, results in an ambiguity or a function that is deleted or
inaccessible from the defaulted constructor, <DEL>or</DEL>
</P></LI>

<LI><P>a direct or virtual base class <TT>B</TT> that cannot be
copied/moved because overload resolution (12.2 [<A href="https://wg21.link/over.match">over.match</A>]),
as applied to <TT>B</TT>'s corresponding constructor, results in an
ambiguity or a function that is deleted or inaccessible from the
defaulted constructor, <DEL>or</DEL>
</P></LI>

<LI><P><INS>any direct or virtual base class or non-static data member
of a type with a destructor that is deleted or inaccessible from the
defaulted constructor,</INS></P></LI>

<LI><P>for the copy constructor, a non-static data member of rvalue
reference type, or</P></LI>

<LI><P>for the move constructor, a non-static data member or direct or
virtual base class with a type that does not have a move constructor
and is not trivially copyable.</P></LI>

</UL>

</BLOCKQUOTE>

</OL>

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