http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494
Andy Lutomirski <luto at mit dot edu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |luto at mit dot edu --- Comment #2 from Andy Lutomirski <luto at mit dot edu> 2012-05-03 21:53:18 UTC --- This seems to have gotten worse in gcc 4.7. This code is now rejected as well: This code: struct A { static void func1() {} }; template<typename T> struct B : public A { void func2() const { func3([&]{ func1(); }); } template<typename Func> void func3(Func f) const { } }; template class B<int>; The error is: template_bug.cc: In instantiation of ‘B<T>::func2() const [with T = int]::<lambda()>’: template_bug.cc:11:22: required from ‘struct B<T>::func2() const [with T = int]::<lambda()>’ template_bug.cc:11:5: required from ‘void B<T>::func2() const [with T = int]’ template_bug.cc:20:16: required from here template_bug.cc:11:16: error: redeclaration of ‘const B<int>* const B<T>::func2() const [with T = int]::<lambda()>::__this’ template_bug.cc:11:22: note: previous declaration ‘const B<int>* const B<T>::func2() const [with T = int]::<lambda()>::__this’ template_bug.cc:11:16: error: redeclaration of ‘const B<int>* const this’ template_bug.cc:11:22: error: ‘const B<int>* const this’ previously declared here template_bug.cc:15:8: error: ‘void B<T>::func3(Func) const [with Func = B<T>::func2() const [with T = int]::<lambda()>; T = int]’, declared using local type ‘B<T>::func2() const [with T = int]::<lambda()>’, is used but never defined [-fpermissive] Your patch fixes this test case, too.