Open
Description
Here's the code sample that demonsrates the problem
struct S
{
enum T { A };
enum class U { B };
};
int main()
{
S s;
S::A; // OK
S::T::A; // OK
S::U::B; // OK
s.A; // OK
s.T::A; // OK
s.U::B; // Error???
}
All six lines that refer to enumerators from enums declared inside class S
are perfectly valid. However, Clang issues an error
error: 'S::U::B' is not a member of class 'S'
17 | s.U::B; // Error???
| ~~~^
for last one (i.e. s.U::B
). Why?
What makes it especially weird is that Clang has no problems with the qualified name in the s.T::A
line, i.e. it does allow one to optionally use a qualified name to access enumerators from a "classic" unscoped enum (using qualified name with such enums is a possibility since C++11). However, for some unknown reason Clang rejects a similar attempt to access an enumerator from a scoped enum.
GCC and MSVC++ have no issues with such code.