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

            Bug ID: 87179
           Summary: duplicate extern "C" functions in different namespaces
                    not flagged as an error
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tiagomacarios at gmail dot com
  Target Milestone: ---

Code below compiles in GCC, but is discarded by clang.

namespace A {
  extern "C" int g() { return 1; }
}

namespace B {
  extern "C" int g() { return 1; }  // ill-formed, the function g with C
language linkage has two definitions
}



clang error:
<source>:6:18: error: redefinition of 'g'

  extern "C" int g() { return 1; }  // ill-formed, the function g with C
language linkage has two definitions

                 ^

<source>:2:18: note: previous definition is here

  extern "C" int g() { return 1; }

                 ^

1 error generated.

Compiler returned: 1


example is a copy and paste from the standard http://eel.is/c++draft/dcl.link#6

Reply via email to