Created attachment 28485 [details] Output of -v option and preprocessed file with GCC 4.8.0 20121014 The following valid code reproduces the problem; ///////////////////////////// template<typename T> struct identity { typedef T type; }; template<typename T> void f() { typedef typename T::type A; int i = 42; int const &cri = i; int volatile &vri = i; [&]() { A const &x = cri; // Problem here A volatile &y = vri; // Likewise }; } int main() { f<identity<int> >(); } ///////////////////////////// In the lambda-expression, initilizations of cv-qualified references are obviously legal. However, GCC 4.8.0 20121014 complains as follows; main.cpp: In instantiation of 'f() [with T = identity<int>]::__lambda0': main.cpp:16:21: required from 'struct f() [with T = identity<int>]::__lambda0' main.cpp:14:3: required from 'void f() [with T = identity<int>]' main.cpp:22:21: required from here main.cpp:15:18: error: invalid initialization of reference of type 'identity<int>::type& {aka int&}' from expression of type 'const int' A const &x = cri; ^ main.cpp:16:21: error: invalid initialization of reference of type 'identity<int>::type& {aka int&}' from expression of type 'volatile int' A volatile &y = vri; ^ The error messages look as if there were no cv-qualifiers in the declarators. Note that GCC 4.7.3 20121013 also fails to compile, but GCC 4.6.4 20121012 compiles successfully.
Thus this seems a regression.
Author: paolo Date: Fri Dec 7 09:53:04 2012 New Revision: 194297 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194297 Log: 2012-12-07 Paolo Carlini <paolo.carlini@oracle.com> PR c++/54975 * g++.dg/cpp0x/lambda/lambda-typedef.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-typedef.C Modified: trunk/gcc/testsuite/ChangeLog
Fixed for 4.7.3 and 4.8 by patch for bug 55058.