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


847. Error in rvalue reference deduction example

Section: 13.10.3.2  [temp.deduct.call]     Status: CD2     Submitter: Steve Adamczyk     Date: 27 March, 2009

[Voted into WP at March, 2010 meeting.]

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.

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.)