Here's a case where Clang and GCC both do the same thing but I don't see
why it is correct.
But, adding the "extern" declaration causes Clang to treat "k2" as
a reference to "aaa::k2" rather than "::k2". I think that's wrong.
There is no aaa:k2 in the above example, have you included an incomplete test?
Cheers,
Rafael
But, adding the "extern" declaration causes Clang to treat "k2" as
a reference to "aaa::k2" rather than "::k2". I think that's wrong.There is no aaa:k2 in the above example, have you included an incomplete test?
Yes, that is the complete test. Clang generates an external reference to
"aaa::k2" which then causes the link to fail.
--paulr
Within an out-of-line declaration, the enclosing namespace is the
original namespace of the entity, not the lexical namespace.
C++11 [namespace.def]p6:
The enclosing namespaces of a declaration are those namespaces in
which the declaration lexically appears, except for a redeclaration of a
namespace member outside its original namespace (e.g., a definition
as specified in 7.3.1.2). Such a redeclaration has the same enclosing
namespaces as the original declaration.
John.
Within an out-of-line declaration, the enclosing namespace is the
original namespace of the entity, not the lexical namespace.C++11 [namespace.def]p6:
The enclosing namespaces of a declaration are those namespaces in
which the declaration lexically appears, except for a redeclaration of a
namespace member outside its original namespace (e.g., a definition
as specified in 7.3.1.2). Such a redeclaration has the same enclosing
namespaces as the original declaration.John.
Okay, so the method definition actually does implicitly reopen the
namespace scope. Thanks for pointing out where that's specified!
--paulr