https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96116
Bug ID: 96116 Summary: GCC accepts "enum struct/class" in reference to enumeration Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi,all. This code, might be an invalid code, but GCC accepts it. $cat test.cc using alias1 = enum struct E1; using alias2 = enum class E2; While in clang: $clang++ test.cc test.cc:1:21: error: reference to enumeration must use 'enum' not 'enum struct' [-Welaborated-enum-class] using alias1 = enum struct E1; ^~~~~~~ test.cc:2:21: error: reference to enumeration must use 'enum' not 'enum class' [-Welaborated-enum-class] using alias2 = enum class E2; ^~~~~~ 2 errors generated. Here is a related bug report in llvm: https://bugs.llvm.org/show_bug.cgi?id=46603 They suggested that ""enum class" can only be used when defining an enumeration or as part of a standalone forward declaration" Versions from 6.1 to trunk behave the same. So is this an invalid code for GCC? Thanks, Haoxin