struct A{ enum class C{ a = 0 }; }; int main(){ A a; auto c = a.C::a; //#1 } > Each enum-name and each unscoped enumerator is declared in the scope that immediately contains the enum-specifier. > An enumerator declared in class scope can be referred to using the class member access operators (::, . (dot) and -> (arrow)), see [expr.ref]. According to the above rule, A::C::a shouldn't appear in the id-expression of a member access expression, which means `#1` should be ill-formed.
Confirmed. GCC 4.7.4 used to ICE on this.
Hmm, MSVC also accepts this code but clang does not.
I think CWG2557 is clear with this aspect https://cplusplus.github.io/CWG/issues/2557.html
Suspending as the defect report is still considered open but is in the process of drafting: https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2557