N4140 [basic.scope.hiding] / 2:
The class name (9.1) or enumeration name (7.2) can be hidden by the variable name, data member, function or enumerator declared in the same scope. If a class or enumeration name and a variable, the data member, function, or enumerator are declared in the same scope (in any order) with the same name, the class or enumeration name is hidden wherever the variable, data member, function, or counter name is visible.
It would seem that the declaration of int E hides the name of the enumeration E in the global area after the int the declaration point. However, the name E::b is an identifier with an identifier-nested name E:: , therefore rules are applied to search for a qualified name. In particular, [basic.lookup.qual] / 1:
The name of a member of a class or namespace or enumerator can be passed after resolving the scope :: operator (5.1), applied to the nested qualifier name, which designates its class, namespace or enumeration. If a :: not preceded by a decltype-specifier, the scope operator in the nested qualifier name, searches for the name that precedes :: only considers namespaces, types, and templates whose specialization is types. [emphasized by me]. If the name found does not indicate a namespace or class, enumeration or dependent type, the program is poorly formed.
So clang matches, GCC and MSVC don't.
Casey source share