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
Consider:
int i = i;
According to 6.9.3.2 [basic.start.static] paragraph 2, i is zero-initialized and then dynamic initialization is applied. However, it is unclear whether the lifetime of i has started at the point when the dynamic initialization occurs. According to 6.7.3 [basic.life] paragraph 1:
... The lifetime of an object of type T begins when:except ...
- 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]),
Possible directions:
The example in 6.9.3.2 [basic.start.static] paragraph 3 suggests the first option.
CWG 2024-01-19
The first option is is intended.
Possible resolution:
Split and change 6.7.3 [basic.life] paragraph 1 as follows:
... 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]. [ Note: In particular, the lifetime of a complete class object begins when the non-delegating constructor returns (11.9.3 [class.base.init]). The lifetime of a complete object with static or thread storage duration begins when static initialization is complete (6.9.3.2 [basic.start.static]). -- end note ]
- storage with the proper alignment and size for type T is obtained, and
itsany initialization(if any)is complete (including vacuous initialization) (9.4 [dcl.init]),The lifetime of an object o of type T ends when: ...