https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121299

            Bug ID: 121299
           Summary: conflicting namespace resolution
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: development at jordi dot vilar.cat
  Target Milestone: ---

'using namespace' should fail if the designated namespace is ambiguous.

The following code illustrates the bug, compiles fine but should fail. (just
using -std=c++23)

namespace A
{
  inline namespace B
  {
    namespace C
    {
      void foo();
    }
  }
  namespace C
  {
    void bar();
  }
  void test()
  {
    // this should compile fine as C::foo and C::bar are not ambiguous
    C::foo(); // -> should resolve to ::A::B::C::foo
    C::bar(); // -> should resolve to ::A::C::bar

    // this should fail, as C is ambiguous
    using namespace C;
    foo();
    bar();
  }
}

This issue can be reproduced in the compiler explorer:
https://godbolt.org/z/4KxGo443W

Reply via email to