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.
Confirmed.
Author: jason Date: Fri May 25 21:03:07 2018 New Revision: 260782 URL: https://gcc.gnu.org/viewcvs?rev=260782&root=gcc&view=rev Log: PR c++/85815 - reference to member of enclosing template. * search.c (lookup_base): Use currently_open_class. (lookup_member): Use it regardless of -fconcepts. * parser.c (cp_parser_postfix_dot_deref_expression): Check it. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/cp/parser.c trunk/gcc/cp/search.c
Author: jason Date: Mon Jun 11 22:01:55 2018 New Revision: 261460 URL: https://gcc.gnu.org/viewcvs?rev=261460&root=gcc&view=rev Log: PR c++/85815 - reference to member of enclosing template. * search.c (lookup_base): Use currently_open_class. (lookup_member): Use it regardless of -fconcepts. * parser.c (cp_parser_postfix_dot_deref_expression): Check it. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/class.c branches/gcc-8-branch/gcc/cp/parser.c branches/gcc-8-branch/gcc/cp/search.c
Fixed for 7.4/8.2.
Author: jason Date: Tue Jun 12 19:53:10 2018 New Revision: 261524 URL: https://gcc.gnu.org/viewcvs?rev=261524&root=gcc&view=rev Log: PR c++/85815 - reference to member of enclosing template. * parser.c (cp_parser_postfix_dot_deref_expression): Check currently_open_class. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-dependent1.C Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/parser.c