https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77812
Bug ID: 77812 Summary: incorrectly rejects valid C++ code that uses enum in template instantiation 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: --- It affects 4.7.x and later, and is a regression from 4.6.x. Both Clang and ICC also accept the code. The code is accepted if a struct is used for template instantiation instead (see small2.cpp). $ 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 20160930 (experimental) [trunk revision 240688] (GCC) $ $ g++-4.6 -c small1.cpp $ clang++-3.8 -c small1.cpp $ $ g++-trunk -c small1.cpp small1.cpp: In function ‘void f()’: small1.cpp:5:12: error: use of enum ‘f’ without previous declaration f < enum f > (); ^ $ $ g++-trunk -c small2.cpp $ $ cat small1.cpp enum f { R, G, B }; template < typename > void f () { f < enum f > (); } $ $ cat small2.cpp struct f {}; template < typename > void f () { f < struct f > (); } $