<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1658</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="1658"></A><H4>1658.
  
Deleted default constructor for abstract class via destructor
</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++14
 &#160;&#160;&#160;

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

 <B>Date: </B>2013-08-26<BR>


<P>[Moved to DR at the February, 2014 meeting.]</P>

<P>While reviewing the resolution of <A HREF="1611.html">issue 1611</A>,
it was noticed that the final bullet of 11.4.5 [<A href="https://wg21.link/class.ctor#4">class.ctor</A>] paragraph 4
has a similar issue:</P>

<BLOCKQUOTE>

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

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

<LI><P>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.</P></LI>

</UL>

</BLOCKQUOTE>

<P>Presumably destructors for virtual bases of abstract classes should
not be considered in making this determination.</P>



<P>A question was also raised regarding whether odr-use is correctly
defined for destructors of virtual bases of abstract classes.
6.3 [<A href="https://wg21.link/basic.def.odr#3">basic.def.odr</A>] paragraph 3 simply refers to
11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>], where the relevant passage (paragraph 8)
reads,</P>

<BLOCKQUOTE>

After executing the body of the destructor and destroying any automatic
objects allocated within the body, a destructor for class <TT>X</TT> calls
the destructors for <TT>X</TT>'s direct non-variant non-static data
members, the destructors for <TT>X</TT>'s direct base classes and,
if <TT>X</TT> is the type of the most derived class
(11.9.3 [<A href="https://wg21.link/class.base.init">class.base.init</A>]), its destructor calls the destructors
for <TT>X</TT>'s virtual base classes.

</BLOCKQUOTE>

<P>It could be argued, particularly in light of the reference to
11.9.3 [<A href="https://wg21.link/class.base.init">class.base.init</A>], that this is clear enough that the
destructor for an abstract class does not invoke destructors for its
virtual bases, but a note to that effect might be helpful.</P>

<P><B>Proposed resolution (November, 2013):</B></P>

<OL>
<LI><P>Add the following as a new paragraph at the end of
11.4.4 [<A href="https://wg21.link/special">special</A>]:</P></LI>

<BLOCKQUOTE>

<INS>For a class, its non-static data members, its non-virtual
direct base classes, and, if the class is not abstract
(11.7.4 [<A href="https://wg21.link/class.abstract">class.abstract</A>]), its virtual base classes are
called its <I>potentially constructed subobjects</I>.</INS>

</BLOCKQUOTE>

<LI><P>Change 11.4.5 [<A href="https://wg21.link/class.ctor#4">class.ctor</A>] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

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

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

<LI><P>any <DEL>direct or virtual base class, or non-static
data member</DEL> <INS>potentially constructed subobject,
except for a non-static data member</INS>
with <DEL>no</DEL> <INS>a</INS> <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, or</P></LI>

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

</UL>

</BLOCKQUOTE>

<LI><P>Change 11.4.7 [<A href="https://wg21.link/class.dtor#5">class.dtor</A>] paragraph 5 as follows:</P></LI>

<BLOCKQUOTE>

<P>A defaulted destructor for a class <TT>X</TT> is defined
as deleted if:</P>

<UL>
<LI><P>X is a union-like class that has a variant member with a
non-trivial destructor,</P></LI>

<LI><P>any <DEL>of the non-static data members</DEL>
<INS>potentially constructed subobject</INS> has class
type <TT>M</TT> (or array thereof) and <TT>M</TT> has a
deleted destructor or a destructor that is inaccessible from
the defaulted destructor,</P></LI>

<LI><P><DEL>any direct or virtual base class has a deleted destructor or
a destructor that is inaccessible from the defaulted
destructor,</DEL></P></LI>

</UL>

</BLOCKQUOTE>

<LI><P>Change 11.9.3 [<A href="https://wg21.link/class.base.init#8">class.base.init</A>] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

In a non-delegating constructor, if a given <DEL>non-static
data member or base class</DEL> <INS>potentially constructed
subobject</INS> is not designated by
a <I>mem-initializer-id</I> (including the case where there
is no <I>mem-initializer-list</I> because the constructor
has no <I>ctor-initializer</I>) <DEL>and the entity is not a
virtual base class of an abstract class
(11.7.4 [<A href="https://wg21.link/class.abstract">class.abstract</A>])</DEL>, then...

</BLOCKQUOTE>

<LI><P>Change 11.9.3 [<A href="https://wg21.link/class.base.init#10">class.base.init</A>] paragraph 10 as follows:</P></LI>

<BLOCKQUOTE>

In a non-delegating constructor, the destructor for each
<DEL>direct or virtual base class and for each non-static
data member</DEL> <INS>potentially constructed
subobject</INS> of class type is potentially invoked
(11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>]). [<I>Note:</I> This provision
ensures that destructors can be called for fully-constructed
sub-objects in case an exception is thrown
(14.3 [<A href="https://wg21.link/except.ctor">except.ctor</A>]). &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#8">class.copy.ctor</A>] paragraph 8, replacing
the bulleted list with a single sentence, as follows:</P></LI>

<BLOCKQUOTE>

<P>The implicitly-declared copy constructor for a
class <TT>X</TT> will have the form</P>

<UL><TT>X::X(const X&amp;)</TT></UL>

<P>if <INS>each potentially constructed subobject</INS>
</P>

<UL>
<LI><P><DEL>each direct or virtual base class <TT>B</TT>
of <TT>X</TT> has a copy constructor whose first parameter
is of type <TT>const B&amp;</TT> or <TT>const volatile B&amp;</TT>,
and</DEL></P></LI>

<LI><P>
<DEL>for all the non-static data members
of <TT>X</TT> that are</DEL> of a class type <TT>M</TT> (or
array thereof)<DEL>, each such class type</DEL> has a copy
constructor whose first parameter is of type <TT>const
M&amp;</TT> or
<TT>const volatile M&amp;</TT>.<SUP>121</SUP>
</P></LI>

</UL>

<P>Otherwise...</P>

</BLOCKQUOTE>

<LI><P>Change 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#11">class.copy.ctor</A>] paragraph 11 as follows:</P></LI>

<BLOCKQUOTE>

<P>An implicitly-declared copy/move constructor is an inline
public member of its class. 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 X is a union-like class,</P></LI>

<LI><P>a <DEL>non-static data member</DEL> <INS>potentially
constructed subobject</INS> 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,</P></LI>

<LI><P><DEL>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></P></LI>

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

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

</UL>

</BLOCKQUOTE>

<LI><P>Change 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#14">class.copy.ctor</A>] paragraph 14 as follows:</P></LI>

<BLOCKQUOTE>

Before the defaulted copy/move constructor for a class is
implicitly defined, all non-user-provided copy/move
constructors for its <DEL>direct and virtual base classes
and its non-static data members</DEL> <INS>potentially
constructed subobjects</INS> shall have been implicitly
defined. [<I>Note:</I> An implicitly-declared copy/move
constructor has an <I>exception-specification</I>
(14.5 [<A href="https://wg21.link/except.spec">except.spec</A>]). &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 11.4.5.3 [<A href="https://wg21.link/class.copy.ctor#23">class.copy.ctor</A>] paragraph 23 as follows:</P></LI>

<BLOCKQUOTE>

<P>A defaulted copy/move assignment operator for class <TT>X</TT> is
defined as deleted if <TT>X</TT> has:</P>

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

<LI><P>a <DEL>non-static data member</DEL> <INS>potentially
constructed subobject</INS> 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 assignment operator, results in an ambiguity
or a function that is deleted or inaccessible from the
defaulted assignment operator<DEL>, or</DEL><INS>.</INS>
</P></LI>

<LI><P><DEL>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 assignment operator, results in an ambiguity
or a function that is deleted or inaccessible from the
defaulted assignment operator.</DEL></P></LI>

</UL>

</BLOCKQUOTE>

</OL>

<P>This resolution also resolves <A HREF="1611.html">issue 1611</A>.</P>

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