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


1600. Erroneous reference initialization in example

Section:  [dcl.type.simple]     Status: CD4     Submitter: Niels Dekker     Date: 2012-12-30

[Moved to DR at the November, 2014 meeting.]

The example in [dcl.type.simple] paragraph 4 reads, in part,

  const int&& foo();
  int i;
  decltype(foo()) x1 = i; // type is const int&&

The initialization is an ill-formed attempt to bind an rvalue reference to an lvalue.

Proposed resolution (April, 2013):

Change the example in [dcl.type.simple] paragraph 4 as follows:

  const int&& foo();
  int i;
  struct A { double x; };
  const A* a = new A();
  decltype(foo()) x1 = i 17;     // type is const int&&
  decltype(i) x2;                // type is int
  decltype(a->x) x3;             // type is double
  decltype((a->x)) x4 = x3;      // type is const double&