[LLVMbugs] [Bug 12299] New: binutils' gold doesn't compile with clang, due to namespace problems

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 18 07:57:23 PDT 2012


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

             Bug #: 12299
           Summary: binutils' gold doesn't compile with clang, due to
                    namespace problems
           Product: new-bugs
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: dimitry at andric.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


When the gold linker in binutils 2.22 got enabled in the FreeBSD port recently,
I noticed it didn't compile with clang.  In particular, it dies on the
following
reduced testcase:

  namespace gold {
    extern "C" {
      extern void script_parse_option(void *closure, const char *option, int
length);
    }
  }

  using namespace gold;

  extern "C" void script_parse_option(void *closurev, const char *option, int
length)
  {
  }

  extern "C" void script_add_search_dir(void *closurev, const char *option, int
length)
  {
    script_parse_option(closurev, "foo", 3);
  }

with the following error:

  gold-namespace.cpp:15:3: error: call to 'script_parse_option' is ambiguous
    script_parse_option(closurev, "foo", 3);
    ^~~~~~~~~~~~~~~~~~~
  gold-namespace.cpp:3:17: note: candidate function
      extern void script_parse_option(void *closure, const char *option, int
length);
          ^
  gold-namespace.cpp:9:17: note: candidate function
  extern "C" void script_parse_option(void *closurev, const char *option, int
length)
          ^

Naturally, gcc has no problem with this code.  Some discussion on #llvm seemed
to indicate this is a clang bug:

  19:45:05<jyasskin_w> "Two declarations for a function with C language linkage
                       with the same function name (ignoringthe namespace names
               that qualify it) that appear in different namespace
               scopes refer to the same function."
  19:45:12<zygoloid> but istr there is some special rule about extern "C"... ^^
                     this rule  
  19:45:15<jyasskin_w> [dcl.link]p6
  [...]
  19:52:38<zygoloid> jyasskin_w: so it seems pretty clear to me that
                     [dcl.link]p6 is supposed to overrule [over.dcl]p1's
             definition of 'refer to the same function'
  19:52:56<zygoloid> (yes, i agree this is well-formed)
  19:53:37<zygoloid> Phlow: the name mangling change is unrelated. name
                     mangling is not involved in overload resolution.
  19:53:49<jyasskin_w> zygoloid: Yeah, it has to.
...
  19:56:09<dim> summarizing then, it's a clang problem? :)
  19:56:18 * dim tries edg just for fun
  20:00:57<zygoloid> dim: yes, clang bug

I'm leaving it here, so it doesn't get lost, hopefully.

-- 
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