The following code:
namespace { constexpr int x = 1; }
namespace X { namespace { constexpr int x = 2; } }
using namespace X;
int main() {
static_assert( ::x == 1 );
}
successfully compiles in MSVC, which prefers the first anonymous namespace in finding of ::x over X::(anonymous namespace).
However both GCC and Clang reject the code due to ambiguity of selection. Demo: https://gcc.godbolt.org/z/zPEGzGar3
Which compiler is right here?