This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1600. Erroneous reference initialization in example

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

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

The example in 9.2.9.3 [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 9.2.9.3 [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&