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
(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:
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: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]. ...
- 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]),
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 variableshave 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. ...
CWG 2024-04-05
CWG preferred to keep the term vacuous initialization and fix its definition while adressing issue 2859.