Created on 2023-07-24.00:00:00 last changed 9 months ago
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: ...
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-02-17 11:33:06 | admin | set | messages: + msg7611 |
2024-02-17 11:33:06 | admin | set | status: open -> review |
2023-07-24 00:00:00 | admin | create |