[Bug c++/94227] New: ambiguous lookup for nested-name-specifier in using-declaration is not diagnosed

richard-gccbugzilla at metafoo dot co.uk gcc-bugzilla@gcc.gnu.org
Thu Mar 19 19:50:11 GMT 2020


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

            Bug ID: 94227
           Summary: ambiguous lookup for nested-name-specifier in
                    using-declaration is not diagnosed
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richard-gccbugzilla at metafoo dot co.uk
  Target Milestone: ---

GCC accepts this invalid code:

namespace N1 {
  int &f();
}

namespace N2 {
  struct N1 {
    float &f();
  };
}

using namespace N2;
int &r = N1::f();


This should be rejected due to ambiguity: the name N1 on the final line is
looked up by unqualified lookup, and that lookup is ambiguous between ::N1 and
::N2::N1. But GCC accepts and selects ::N1.

(Originally filed as a Clang rejects-valid here: https://llvm.org/PR45216)


More information about the Gcc-bugs mailing list