Namespace using declaration (bug in GCC/VS2010)?

前端 未结 2 1861
namespace A{
   int i;
}

int main(){
   using A::i;
   using A::i;
}

VS2010 - compiles fine

gcc (ideone) - compiles fine

Comeau -

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-19 00:08

    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.

提交回复
热议问题