
5 Mar
2011
5 Mar
'11
5:35 p.m.
Michel MORIN wrote:
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
// Commenting this out makes compilation succeed void f() { int i = 0; auto&& x = identity(i); // In a function template, auto deduction fails } int main (int argc, char* argv[]) { f(); return 0; }
This seems an unknown bug of gcc, so I reported this to GCC Bugzilla: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47999 Good thing you found this problem, Nate! Regards, Michel