possibly ambiguous wording in [namespace.udir]p6

I

Ivan Sorokin

Is the following code a correct C++ program?

namespace a
{
struct x
{};
}

namespace b
{
namespace d = a;
}

namespace c
{
namespace d = a;
}

using namespace b;
using namespace c;

d::x x;

Is "d" in "d::x" ambiguous or not? MSVC accepts this code, while
clang, gcc and EDG reject it.

[namespace.udir]p3: If name lookup finds a declaration for a name in
two different namespaces, and the declarations do not declare the same
entity and do not declare functions, the use of the name is ill-
formed.

Does namespace-alias declares new entity or refers to existing?

According to [namespace.alias]p3 redefinition of namespace-alias in
the same declarative region is ok as long as it refers to the same
namespace, but [namespace.alias]p3 doesn't say anything about
interaction with using-directives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top