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


706. Use of auto with rvalue references

Section:  []     Status: NAD     Submitter: Jonathan Caves     Date: 1 Aug, 2008

Because type deduction for the auto specifier is described in [] paragraph 6 as equivalent to the deduction that occurs in a call to a function template, the adjustment of the argument type from A to A& specified in [] paragraph 3 is performed when the initializer is an lvalue. As a result, in the following example, ra has the type A& and not, as might be expected, A&&:

    class A { };

    void f() {
       A a;
       auto&& ra = a;

It is unclear whether this is surprising enough, and potentially widely-enough used, to warrant making an exception to the current rules to handle this case differently.

Rationale (September, 2008):

It is important that the deduction rules be the same in the function and auto cases. The result of this example might be surprising, but maintaining a consistent model for deduction is more important.