[LLVMbugs] [Bug 11759] New: bogus ambiguity error for extern "C" function redeclared in different namespaces

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jan 13 06:11:03 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=11759

             Bug #: 11759
           Summary: bogus ambiguity error for extern "C" function
                    redeclared in different namespaces
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: zilla at kayari.org
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


[dcl.link]/6 says
At most one function with a particular name can have C language linkage. Two
declarations for a function with C language linkage with the same function name
(ignoring the namespace names that qualify it) that appear in different
namespace scopes refer to the same function.

Clang++ disagrees, so the example from [namespace.udir]/6 fails

namespace A {
  class X { };
  extern "C" int g();
  extern "C++" int h();
}
namespace B {
  void X(int);
  extern "C" int g();
  extern "C++" int h(int);
}
using namespace A;
using namespace B;
void f() {
  // X(1); // error: name X found in two namespaces
  g(); // okay: name g refers to the same entity
  h(); // okay: overload resolution selects A::h
}


d.cc:15:3: error: call to 'g' is ambiguous
  g(); // okay: name g refers to the same entity
  ^
d.cc:3:18: note: candidate function
  extern "C" int g();
                 ^
d.cc:8:18: note: candidate function
  extern "C" int g();
                 ^

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list