https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71662
Bug ID: 71662 Summary: ICE on invalid C++11 code with unqualified name look up: in tsubst_copy, at cp/pt.c:14010 Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following C++11 code causes an ICE when compiled with the current GCC trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes. It also affects older versions at least as early as 4.6.x. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20160625 (experimental) [trunk revision 237780] (GCC) $ $ g++-trunk -c -std=c++11 small.cpp small.cpp: In instantiation of ‘A<T>::E A<T>::h() [with T = int]’: small.cpp:8:23: required from here small.cpp:14:10: internal compiler error: in tsubst_copy, at cp/pt.c:14010 return e; ^ 0x6dfcdc tsubst_copy ../../gcc-source-trunk/gcc/cp/pt.c:14010 0x6e2906 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc-source-trunk/gcc/cp/pt.c:17243 0x6d68ff tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15868 0x6d6f75 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15176 0x6d7e30 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../gcc-source-trunk/gcc/cp/pt.c:15351 0x6d4835 instantiate_decl(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/pt.c:22095 0x721512 instantiate_pending_templates(int) ../../gcc-source-trunk/gcc/cp/pt.c:22214 0x764645 c_parse_final_cleanups() ../../gcc-source-trunk/gcc/cp/decl2.c:4600 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ ---------------------------------------------------------- template < typename T > struct A { enum E : T; E h (); }; A < int > a; A < int >::E b = a.h (); template < typename T > enum A < T >::E : T { e }; template < typename T > typename A < T >::E A < T >::h () { return e; }