https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86384
Bug ID: 86384 Summary: Scoped enumeration instantiated even if not required Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- The code is as follow: template<typename T> struct A { enum class B { X = T::value }; }; int main() { A<int> a; } g++ error: code0.c.cpp:4:13: error: 'value' is not a member of 'int' enum class B { ^ This code looks well-formed. Only if we look into the enumeration, as "A<int>::B::X", the definition of the enumeration is required to exist and thus implicitly instantiated. This is specified at 14.7.1p1 and p2. I tried clang++. It accepts the code without any error message.