Title
Error in rvalue reference deduction example
Status
cd2
Section
13.10.3.2 [temp.deduct.call]
Submitter
Steve Adamczyk

Created on 2009-03-27.00:00:00 last changed 171 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-07-15.00:00:00

Proposed resolution (July, 2009):

Replace the example in 13.10.3.2 [temp.deduct.call] paragraph 3 with:

    template<typename T> int f(T&&);
    template<typename T> int g(const T&&);
    int i;
    int n1 = f(i);    // calls f<int&>(int&)
    int n2 = f(0);    // calls f<int>(int&&)
    int n3 = g(i);    // error: would call g<int>(const int&&), which would
                      // bind an rvalue reference to an lvalue

(See also issue 858.)

Date: 2009-08-03.00:00:00

The adoption of paper N2844 made it ill-formed to attempt to bind an rvalue reference to an lvalue. However, the example in 13.10.3.2 [temp.deduct.call] paragraph 3 still reflects the previous specification:

    template <typename T> int f(T&&);
    int i;
    int j = f(i);        // calls f<int&>(i)
    template <typename T> int g(const T&&);
    int k;
    int n = g(k);        // calls g<int>(k)

The last line of that example is now ill-formed, attempting to bind the const int&& parameter of g to the lvalue k.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2742
2010-03-29 00:00:00adminsetstatus: ready -> cd2
2009-11-08 00:00:00adminsetstatus: review -> ready
2009-08-03 00:00:00adminsetmessages: + msg2188
2009-08-03 00:00:00adminsetstatus: open -> review
2009-03-27 00:00:00admincreate