This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2012. Lifetime of references

Section: 6.7.5  []     Status: CD4     Submitter: Mike Miller     Date: 2014-09-29

[Adopted at the February, 2016 meeting.]

According to 6.7.5 [] 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 [] and it should be described properly in 6.7.3 [].

Proposed resolution (September, 2015):

  1. Change 6.7.5 [] paragraph 3 as follows:

  2. The storage duration categories apply to references as well. The lifetime of a reference is its storage duration.
  3. Change 6.7.3 [] paragraph 1 as follows:

  4. The lifetime of an object or reference is a runtime property of the object or reference. An object is said to have...
  5. Add the following as a new paragraph following 6.7.5 [] paragraph 2:

  6. [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]

    The lifetime of a reference begins when its initialization is complete. The lifetime of a reference ends as if it were a scalar object.

  7. Change 6.7.3 [] paragraph 3 as follows:

  8. The properties ascribed to objects and references throughout this International Standard apply for a given object or reference only during its lifetime. [Note:...

    Change Clause 7 [expr] paragraph 5 as follows:

    If an expression initially has the type “reference to T” ( [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. [Note: Before the lifetime of the reference has started or after it has ended, the behavior is undefined (see 6.7.3 []). —end note]

Drafting note: there is no change to 6.7.3 [] 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...