https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85815
Bug ID: 85815 Summary: incorrect "invalid use of incomplete type" in a lambda on valid code Product: gcc Version: 7.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: v at vsamko dot com Target Milestone: --- This valid code: template<class T> class A { static A* INSTANCE; void foobar(); void moo() {} }; template<class T> A<T>* A<T>::INSTANCE = nullptr; template<class T> void A<T>::foobar() { auto x = []() { INSTANCE->moo(); }; } (compiled with -Wall) Gives error: <source>: In lambda function: <source>:14:17: error: invalid use of incomplete type 'class A<T>' [-Werror] INSTANCE->moo(); This compiles fine with Clang and GCC 6, but fails with the error above with GCC 7 and 8.