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 2 months ago

Messages

Date: 2023-07-14.22:46:13

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

  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.7.3 [basic.life]) before all delegating constructors have completed. -- end note]

  2. Change in 6.7.3 [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.4 [dcl.init], 11.9.3 [class.base.init]),
    except that ...
Date: 2023-06-20.00:00:00

Subclause 6.7.3 [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.4 [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
2023-07-14 22:46:13adminsetstatus: open -> tentatively ready
2023-06-30 14:12:45adminsetmessages: + msg7348
2023-06-20 00:00:00admincreate