Namespace using declaration (bug in GCC/VS2010)?

ε祈祈猫儿з 提交于 2019-11-29 09:28:50

The example you refer to is known to be inconsistent. The committee hasn't yet fixed this.

So, is this a bug in GCC and VS2010?

I don't think it's a bug in either of GCC/VS2010/Clang or Comeau. It appears to be a bug in the C++ Standard. In these cases, compile writers have to make up their mind on what is most viable. If you remove the example in question, then 3.3/4 states the example is valid: "Given a set of declarations in a single declarative region, each of which specifies the same unqualified name, ... they shall all refer to the same entity, or all refer to functions and function templates; or ...".

The question arises, as discussed in the linked issue, what 7.3.3/8 refers to when it says "declarations", which the committee didn't reach consensus about. And so, until then 3.3/4 applies for GCC/VS2010 and Clang, while Comeau chooses to use some other semantics.

Yes you are right. This is indeed a bug in g++, MSVC++ and Clang. Comeau has got it correct.

As you said 7.3.3/8 says

A using-declaration is a declaration and can therefore be used repeatedly where (and only where) multiple declarations are allowed

The following code snippet is also given.

void f()
{
    using A::i;
    using A::i;  //error: double declaration
}

Similarly your code is ill-formed too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!