http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57526
Bug ID: 57526 Summary: use of X before deduction of auto error for seemingly good code Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: plasmahh at gmx dot net Hi, for the following code template<class T> struct A { void bar( ) { } void foo( ) { auto* this_ptr = this; auto lc = [&]( ) { this_ptr->bar(); }; lc(); } }; int main(int argc, const char *argv[]) { A<int> a; a.foo(); } I get gcc 4.8.{0,1} error me out with: auto.cxx:12:4: error: use of 'A<T>::foo() [with T = int]::__lambda0::__this_ptr' before deduction of 'auto' this_ptr->bar(); which for one was not the case with gcc 4.7. There are two (strange) ways to make it go away: Either make it be "auto" isntead of "auto*" or make A not being a template. I also could not find anything in the standard that would disallow this.