Created on 2014-09-29.00:00:00 last changed 49 months ago
Proposed resolution (September, 2015):
Change 6.7.5 [basic.stc] paragraph 3 as follows:
The storage duration categories apply to references as well.
The lifetime of a reference is its storage duration.
Change 6.7.3 [basic.life] paragraph 1 as follows:
The lifetime of an object is a runtime property of the object . An object is said to have...
Add the following as a new paragraph following 6.7.5 [basic.stc] paragraph 2:
[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]
Change 6.7.3 [basic.life] paragraph 3 as follows:
The properties ascribed to objects throughout this International Standard apply for a given object only during its lifetime. [Note:...
Change Clause 7 [expr] paragraph 5 as follows:
If an expression initially has the type “reference to T” (126.96.36.199 [dcl.ref], 9.4.4 [dcl.init.ref]), the type is adjusted to T prior to any further analysis. The expression designates the object or function denoted by the reference, and the expression is an lvalue or an xvalue, depending on the expression.
Drafting note: there is no change to 6.7.3 [basic.life] paragraph 4:
A program may end the lifetime of any object by reusing the storage which the object occupies or by explicitly calling the destructor for an object of a class type with a non-trivial destructor. For an object of a class type...
[Adopted at the February, 2016 meeting.]
According to 6.7.5 [basic.stc] paragraph 3,
The storage duration categories apply to references as well. The lifetime of a reference is its storage duration.
This is clearly not correct; references can have static storage duration but be dynamically initialized. Consider an example like:
extern int& r1; int& f(); int& r2 = r1; // #1 int& r1 = f(); int i = r2; // #2
r1 is not initialized until after its use at #1, so the initialization of r2 should produce undefined behavior, as should the use of r2 at #2.
The description of the lifetime of a reference should be deleted from 6.7.5 [basic.stc] and it should be described properly in 6.7.3 [basic.life].
|2017-02-06 00:00:00||admin||set||status: tentatively ready -> cd4|
|2015-11-10 00:00:00||admin||set||messages: + msg5590|
|2015-11-10 00:00:00||admin||set||status: drafting -> tentatively ready|
|2015-05-25 00:00:00||admin||set||status: open -> drafting|