Created on 2013-08-26.00:00:00 last changed 122 months ago
[Moved to DR at the February, 2014 meeting.]
Proposed resolution (November, 2013):
Add the following as a new paragraph at the end of 11.4.4 [special]:
For a class, its non-static data members, its non-virtual direct base classes, and, if the class is not abstract (11.7.4 [class.abstract]), its virtual base classes are called its potentially constructed subobjects.
Change 11.4.5 [class.ctor] paragraph 4 as follows:
...A defaulted default constructor for class X is defined as deleted if:
...
any
direct or virtual base class, or non-static data memberpotentially constructed subobject, except for a non-static data member withnoa brace-or-equal-initializer, has class type M (or array thereof) and either M has no default constructor or overload resolution (12.2 [over.match]) as applied to M's default constructor results in an ambiguity or in a function that is deleted or inaccessible from the defaulted default constructor, orany
direct or virtual base class or non-static data memberpotentially constructed subobject has a type with a destructor that is deleted or inaccessible from the defaulted default constructor.
Change 11.4.7 [class.dtor] paragraph 5 as follows:
A defaulted destructor for a class X is defined as deleted if:
X is a union-like class that has a variant member with a non-trivial destructor,
any
of the non-static data memberspotentially constructed subobject has class type M (or array thereof) and M has a deleted destructor or a destructor that is inaccessible from the defaulted destructor,
any direct or virtual base class has a deleted destructor or a destructor that is inaccessible from the defaulted destructor,
Change 11.9.3 [class.base.init] paragraph 8 as follows:
In a non-delegating constructor, if a givennon-static data member or base classpotentially constructed subobject is not designated by a mem-initializer-id (including the case where there is no mem-initializer-list because the constructor has no ctor-initializer)and the entity is not a virtual base class of an abstract class (11.7.4 [class.abstract]), then...
Change 11.9.3 [class.base.init] paragraph 10 as follows:
In a non-delegating constructor, the destructor for eachdirect or virtual base class and for each non-static data memberpotentially constructed subobject of class type is potentially invoked (11.4.7 [class.dtor]). [Note: This provision ensures that destructors can be called for fully-constructed sub-objects in case an exception is thrown (14.3 [except.ctor]). —end note]
Change 11.4.5.3 [class.copy.ctor] paragraph 8, replacing the bulleted list with a single sentence, as follows:
The implicitly-declared copy constructor for a class X will have the form
X::X(const X&)
if each potentially constructed subobject
each direct or virtual base class B of X has a copy constructor whose first parameter is of type const B& or const volatile B&, and
for all the non-static data members of X that areof a class type M (or array thereof), each such class typehas a copy constructor whose first parameter is of type const M& or const volatile M&.121Otherwise...
Change 11.4.5.3 [class.copy.ctor] paragraph 11 as follows:
An implicitly-declared copy/move constructor is an inline public member of its class. A defaulted copy/move constructor for a class X is defined as deleted (9.5.3 [dcl.fct.def.delete]) if X has:
a variant member with a non-trivial corresponding constructor and X is a union-like class,
a
non-static data memberpotentially constructed subobject of class type M (or array thereof) that cannot be copied/moved because overload resolution (12.2 [over.match]), as applied to M's corresponding constructor, results in an ambiguity or a function that is deleted or inaccessible from the defaulted constructor,
a direct or virtual base class B that cannot be copied/moved because overload resolution (12.2 [over.match]), as applied to B's corresponding constructor, results in an ambiguity or a function that is deleted or inaccessible from the defaulted constructor,any
direct or virtual base class or non-static data memberpotentially constructed subobject of a type with a destructor that is deleted or inaccessible from the defaulted constructor, or,...
Change 11.4.5.3 [class.copy.ctor] paragraph 14 as follows:
Before the defaulted copy/move constructor for a class is implicitly defined, all non-user-provided copy/move constructors for itsdirect and virtual base classes and its non-static data memberspotentially constructed subobjects shall have been implicitly defined. [Note: An implicitly-declared copy/move constructor has an exception-specification (14.5 [except.spec]). —end note]
Change 11.4.5.3 [class.copy.ctor] paragraph 23 as follows:
A defaulted copy/move assignment operator for class X is defined as deleted if X has:
...
a
non-static data memberpotentially constructed subobject of class type M (or array thereof) that cannot be copied/moved because overload resolution (12.2 [over.match]), as applied to M's corresponding assignment operator, results in an ambiguity or a function that is deleted or inaccessible from the defaulted assignment operator, or.
a direct or virtual base class B that cannot be copied/moved because overload resolution (12.2 [over.match]), as applied to B's corresponding assignment operator, results in an ambiguity or a function that is deleted or inaccessible from the defaulted assignment operator.
This resolution also resolves issue 1611.
While reviewing the resolution of issue 1611, it was noticed that the final bullet of 11.4.5 [class.ctor] paragraph 4 has a similar issue:
...A defaulted default constructor for class X is defined as deleted if:
...
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.
Presumably destructors for virtual bases of abstract classes should not be considered in making this determination.
A question was also raised regarding whether odr-use is correctly defined for destructors of virtual bases of abstract classes. 6.3 [basic.def.odr] paragraph 3 simply refers to 11.4.7 [class.dtor], where the relevant passage (paragraph 8) reads,
After executing the body of the destructor and destroying any automatic objects allocated within the body, a destructor for class X calls the destructors for X's direct non-variant non-static data members, the destructors for X's direct base classes and, if X is the type of the most derived class (11.9.3 [class.base.init]), its destructor calls the destructors for X's virtual base classes.
It could be argued, particularly in light of the reference to 11.9.3 [class.base.init], 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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-11-24 00:00:00 | admin | set | status: dr -> c++14 |
2014-03-03 00:00:00 | admin | set | messages: + msg4957 |
2014-03-03 00:00:00 | admin | set | status: tentatively ready -> dr |
2014-01-20 00:00:00 | admin | set | messages: + msg4735 |
2014-01-20 00:00:00 | admin | set | status: drafting -> tentatively ready |
2013-10-14 00:00:00 | admin | set | status: open -> drafting |
2013-08-26 00:00:00 | admin | create |