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

2026-05-19


2756. Completion of initialization by delegating constructor

Section: 11.9  [class.init]     Status: review     Submitter: Brian Bi     Date: 2023-06-20

Subclause 6.8.4 [basic.life] paragraph 1 specifies:

... The lifetime of an object of type T begins when: except that ...

It is unclear whether initialization is considered complete when the (ultimate) target constructor completes, or when the outermost delegating constructor completes. Subclause 14.3 [except.ctor] paragraph 4 suggests it is the former:

If the compound-statement of the function-body of a delegating constructor for an object exits via an exception, the object's destructor is invoked. ...

Proposed resolution (approved by CWG 2023-07-14) [SUPERSEDED]:

  1. Split and change 11.9.3 [class.base.init] paragraph 9 as follows:

    [Note 3: An abstract class ... -- end note ] An attempt to initialize more than one non-static data member of a union renders the program ill-formed. [Note 4: After the call to a constructor for class X ... -- end note ] [Example 6: ... -- end example ]

    An attempt to initialize more than one non-static data member of a union renders the program ill-formed.

    An object's initialization is considered complete when a non-delegating constructor for that object returns. [Note: Therefore, an object's lifetime can begin (6.8.4 [basic.life]) before all delegating constructors have completed. -- end note]

  2. Change in 6.8.4 [basic.life] bullet 1.2 as follows:

    ... The lifetime of an object of type T begins when:
    • storage with the proper alignment and size for type T is obtained, and
    • its initialization (if any) is complete (including vacuous initialization) (9.5 [dcl.init], 11.9.3 [class.base.init]),
    except that ...

CWG 2023-10-20

Utterances about "during construction or destruction" in 11.9.5 [class.cdtor] need to be adjusted.

Possible resolution:

  1. Split and change 11.9.3 [class.base.init] paragraph 9 as follows:

    [Note 3: An abstract class ... -- end note ] An attempt to initialize more than one non-static data member of a union renders the program ill-formed. [Note 4: After the call to a constructor for class X ... -- end note ] [Example 6: ... -- end example ]

    An attempt to initialize more than one non-static data member of a union renders the program ill-formed.

    An object's initialization is considered complete when a non-delegating constructor for that object returns. [Note: Therefore, an object's lifetime can begin (6.8.4 [basic.life]) before all delegating constructors have completed. -- end note]

  2. Change in 6.8.4 [basic.life] bullet 1.2 as follows:

    ... The lifetime of an object of type T begins when:
    • storage with the proper alignment and size for type T is obtained, and
    • its initialization (if any) is complete (including vacuous initialization) (9.5 [dcl.init], 11.9.3 [class.base.init]),
    except that ...
  3. Change in 11.9.5 [class.cdtor] paragraph 2 as follows:

    During the construction initialization of an object, if the value of the object or any of its subobjects is accessed through a glvalue that is not obtained, directly or indirectly, from the constructor's this pointer, the value of the object or subobject thus obtained is unspecified.