Created on 2010-09-02.00:00:00 last changed 131 months ago
[Voted into the WP at the March, 2011 meeting.]
Proposed resolution (January, 2011):
Add a new bullet to 11.4.5 [class.ctor] paragraph 5 as follows:
...A defaulted default constructor for class X is defined as deleted if:
...
X is a non-union class and all members of any anonymous union member are of const-qualified type (or array thereof),
orany direct or virtual base class, or non-static data member with no 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 member has a type with a destructor that is deleted or inaccessible from the defaulted default constructor.
Add a new bullet to 11.4.5.3 [class.copy.ctor] paragraph 12 as follows:
...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 member 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,
ora 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,
orany 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,
for the copy constructor, a non-static data member of rvalue reference type, or
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.
Notes from the November, 2010 meeting:
The CWG agreed that a change was needed, but only if one or more base and/or member constructors are non-trivial.
Consider the following example:
struct A { A(); ~A() = delete; }; struct B: A { }; B* b = new B;
Under the current rules, B() is not deleted, but is ill-formed because it calls the deleted ~A::A() if it exits via an exception after the completion of the construction of A. A deleted subobject destructor should be added to the list of reasons for implicit deletion in 11.4.5 [class.ctor] and 11.4.5.3 [class.copy.ctor].
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-03-03 00:00:00 | admin | set | status: fdis -> c++11 |
2011-04-10 00:00:00 | admin | set | messages: + msg3362 |
2011-04-10 00:00:00 | admin | set | status: tentatively ready -> fdis |
2011-02-28 00:00:00 | admin | set | messages: + msg3234 |
2011-02-28 00:00:00 | admin | set | status: drafting -> tentatively ready |
2010-11-29 00:00:00 | admin | set | messages: + msg3124 |
2010-11-29 00:00:00 | admin | set | status: open -> drafting |
2010-09-02 00:00:00 | admin | create |