This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


1191. Deleted subobject destructors and implicitly-defined constructors

Section: 11.4.5  [class.ctor]     Status: C++11     Submitter: Jason Merrill     Date: 2010-09-02

[Voted into the WP at the March, 2011 meeting.]

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].

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.

Proposed resolution (January, 2011):

  1. Add a new bullet to 11.4.5 [class.ctor] paragraph 5 as follows:

  2. ...A defaulted default constructor for class X is defined as deleted if:

  3. Add a new bullet to 11.4.5.3 [class.copy.ctor] paragraph 12 as follows:

  4. ...A defaulted copy/move constructor for a class X is defined as deleted (9.5.3 [dcl.fct.def.delete]) if X has: