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

2024-12-19


858. Example binding an rvalue reference to an lvalue

Section: Clause 7  [expr]     Status: CD2     Submitter: Daniel Krügler     Date: 6 April, 2009

[Voted into WP at March, 2010 meeting as part of document N3055.]

The adoption of paper N2844 made it ill-formed to attempt to bind an rvalue reference to an lvalue, but the example in Clause 7 [expr] paragraph 6 was overlooked in making this change:

    struct A { };
    A&& operator+(A, A);
    A&& f();

    A a;
    A&& ar = a;

The last line should be changed to use something like static_cast<A&&>(a).

(See also issue 847.)

Proposed resolution (July, 2009):

Change the example in Clause 7 [expr] paragraph 6 as follows:

[Example:

  struct A { };
  A&& operator+(A, A);
  A&& f();

  A a;
  A&& ar = static_cast<A&&>(a);

The expressions f() and a + a are rvalues of type A. The expression ar is an lvalue of type A. —end example]