Code example:
struct A {};
struct B { using A = A; };
int main()
{
B b;
}
Clang compiles it. But GCC gives the following error (demo):
declaration of 'using A = struct A' changes meaning of 'A'
The C++ standard says:
If a class name ([class.name]) or enumeration name ([dcl.enum]) and a variable, data member, function, or enumerator are declared in the same declarative region (in any order) with the same name (excluding declarations made visible via using-directives ([basic.lookup.unqual])), the class or enumeration name is hidden wherever the variable, data member, function, or enumerator name is visible.
UPD.0: thanks to Vlad from Moscow
A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule
Does that mean that GCC behavior is incorrect? Thanks!