Title
Completion of initialization by delegating constructor
Status
tentatively ready
Section
11.9 [class.init]
Submitter
Brian Bi

Created on 2023-06-20.00:00:00 last changed 1 week ago

Messages

Date: 2026-05-20.07:13:21

CWG 2026-05-19

For e.g. a virtual base class VB that inherits constructors, the vtable will not be in its final state while executing inheriting constructors of VB, therefore 11.9.5 [class.cdtor] paragraph 4 through 6 are correct as written.

Date: 2026-05-20.07:13:21

Proposed resolution (approved by CWG 2026-05-19):

  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.
Date: 2025-11-06.23:04:52

CWG 2023-10-20

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

Date: 2024-10-12.06:57:33

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 ...
Date: 2023-06-20.00:00:00

Subclause 6.8.4 [basic.life] paragraph 1 specifies:

... 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]),
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. ...
History
Date User Action Args
2026-05-20 07:13:21adminsetmessages: + msg8585
2026-05-20 07:13:21adminsetstatus: review -> tentatively ready
2025-11-06 23:04:52adminsetmessages: + msg8249
2023-10-20 21:07:14adminsetmessages: + msg7469
2023-10-20 21:07:14adminsetstatus: tentatively ready -> review
2023-07-14 22:46:13adminsetstatus: open -> tentatively ready
2023-06-30 14:12:45adminsetmessages: + msg7348
2023-06-20 00:00:00admincreate