It's not allowed to put a namespace and a class with the same name into one declarative region, i.e.
namespace A {}
class A{};
is ill-formed (see §3.3.1/4). However, one can introduce the name of either one via a using-directive:
namespace N { namespace A {int i;} }
struct A {static int i;};
using namespace N;
int i = A::i; // The global struct, or namespace N::A?
Is this code ill-formed? VC++ thinks so, as well as Clang:
main.cpp:7:9: error: reference to 'A' is ambiguous int i = A::i; ^ main.cpp:3:8: note: candidate found by name lookup is 'A' struct A {static int i;}; ^ main.cpp:1:25: note: candidate found by name lookup is 'N::A' namespace N { namespace A {int i;} } ^
However, GCC accepts it.
Who is right?