Consider the code:
template<typename T>
class Foo{};
namespace X
{
class X{};
}
using namespace X; // now both class X and namespace X are visible
Foo<X::X> f()
{
return {};
}
int main() {}
gcc5.2 compiles the code with no errors whatsoever. However clang spits the error:
error: 'X' is not a class, namespace, or enumeration Foo f()
error: reference to 'X' is ambiguous
Is the code syntactically valid, according to the C++ standard? Or is just a gcc bug? Removing the qualified name X::X
and using Foo<X>
instead makes gcc choke also
error: template argument 1 is invalid Foo f()