Title
Remove and fix the term "vacuous initialization"
Status
dup
Section
6.7.3 [basic.life]
Submitter
Jiang An

Created on 2024-02-21.00:00:00 last changed 7 months ago

Messages

Date: 2024-04-05.21:08:10

CWG 2024-04-05

CWG preferred to keep the term vacuous initialization and fix its definition while adressing issue 2859.

Date: 2024-02-21.00:00:00

(From submission #505.)

A class may have a trivial default constructor that is not actually used to default-initialize a class object, e.g. because the constructor is not eligible. The definition of "vacuous initialization" in 6.7.3 [basic.life] paragraph 1, as used in 8.8 [stmt.dcl] paragraph 2, does not reflect that fact.

Possible resolution:

  1. Change in 6.7.3 [basic.life] paragraph 1 as follows:

    The lifetime of an object or reference is a runtime property of the object or reference. A variable is said to have vacuous initialization if it is default-initialized and, if it is of class type or a (possibly multidimensional) array thereof, that class type has a trivial default constructor. 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 if the object is a union member or subobject thereof, its lifetime only begins if that union member is the initialized member in the union (9.4.2 [dcl.init.aggr], 11.9.3 [class.base.init]), or as described in 11.5 [class.union], 11.4.5.3 [class.copy.ctor], and 11.4.6 [class.copy.assign], and except as described in 20.2.10.2 [allocator.members]. ...
  2. Change in 8.8 [stmt.dcl] paragraph 2 as follows:

    A variable with automatic storage duration (6.7.5.4 [basic.stc.auto]) is active everywhere in the scope to which it belongs after its init-declarator . Upon each transfer of control (including sequential execution of statements) within a function from point P to point Q, all variables with automatic storage duration that are active at P and not at Q are destroyed in the reverse order of their construction. Then, all variables with automatic storage duration that are active at Q but not at P are initialized in declaration order; unless all such variables have vacuous initialization (6.7.3 [basic.life]) are default-initialized and no initialization is performed for any such variable other than calling a trivial default constructor, the transfer of control shall not be a jump. [ Footnote: ... ] When a declaration-statement is executed, P and Q are the points immediately before and after it; when a function returns, Q is after its body. ...
History
Date User Action Args
2024-04-05 21:08:10adminsetmessages: + msg7654
2024-04-05 21:08:10adminsetstatus: open -> dup
2024-02-21 00:00:00admincreate