Created on 2011-04-02.00:00:00 last changed 95 months ago
Proposed resolution (October, 2015):
Change 6.7.4 [basic.life] paragraphs 1 and 2 as follows:
The lifetime of an object is a runtime property of the object. An object is said to have non-vacuous initialization if it is of a class or aggregate type and it or one of its
memberssubobjects is initialized by a constructor other than a trivial default constructor. [Note: initialization...[Note:
The lifetime of an array object starts as soon as storage with proper size and alignment is obtained, and its lifetime ends when the storage which the array occupies is reused or released.11.9.3 [class.base.init] describes the lifetime of base and member subobjects. —end note]
[Adopted at the February, 2016 meeting.]
The note in 6.7.4 [basic.life] paragraph 2 reads,
[Note: The lifetime of an array object starts as soon as storage with proper size and alignment is obtained, and its lifetime ends when the storage which the array occupies is reused or released. 11.9.3 [class.base.init] describes the lifetime of base and member subobjects. —end note]
This wording reflects an earlier version of paragraph 1 that deferred the start of an object's lifetime only for initialization of objects of class type. The note simply emphasized the implication that that the lifetime of a POD type or an array began immediately, even if lifetime of an array's elements began later.
The decomposition of POD types removed the mention of PODs, leaving only the array types, and when the normative text was changed to include aggregates whose members have non-trivial initialization, the note was overlooked.
It is not clear whether it would be better to update the note to emphasize the distinction between aggregates with non-trivial initialization and those without or to delete it entirely.
A possible related normative change to consider is whether the specification of paragraph 1 is sufficiently clear with respect to multidimensional arrays. The current definition of “non-trivial initialization” is:
An object is said to have non-trivial initialization if it is of a class or aggregate type and it or one of its members is initialized by a constructor other than a trivial default constructor.
Presumably the top-level array of an N-dimensional array whose ultimate element type is a class type with non-trivial initialization would also have non-trivial initialization, but it's not clear that this wording says that.
A more radical change that came up in the discussion was whether the undefined behavior resulting from an lvalue-to-rvalue conversion of an uninitialized object in 7.3.2 [conv.lval] paragraph 1 would be better dealt with as a lifetime violation instead.
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-02-06 00:00:00 | admin | set | status: tentatively ready -> cd4 |
2015-11-10 00:00:00 | admin | set | messages: + msg5591 |
2015-11-10 00:00:00 | admin | set | status: drafting -> tentatively ready |
2011-04-02 00:00:00 | admin | create |