
Sebastian Redl wrote:
template<typename> void f() { int A[6]; for(auto&& x : A) ; }
Why does this compile? I don't see how any rvalue can be available in that context.
Wouldn't auto deduction make x an lvalue reference here?
Yes, x should be an lvalue reference here. The code should compile fine.
I think this is a gcc bug.
In a function template, auto deduction fails to deduce an lvalue reference
when auto&& is initiliazed by a function return value of an lvalue reference.
Minimal test case:
(This code fails to be compiled.)
int& identity(int& i)
{
return i;
}
template