This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/63769] New: accepts-invalid multiple function definitions in extern "C"


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

            Bug ID: 63769
           Summary: accepts-invalid multiple function definitions in
                    extern "C"
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nlewycky at google dot com

"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 two different
namespace scopes refer to the same function." - (N4141) C++14 [dcl.link]
paragraph 6.

Testcase:
extern "C" {
  namespace ns1 {
    void foo() {}
  }
  namespace ns2 {
    void foo() {}
  }
}

GCC compiles this and emits assembly, if assembled the assembler will complain
about symbol 'foo' already being defined.

Clang complains about the redeclaration:
x.cc:6:10: error: redefinition of 'foo'
    void foo() {}
         ^
x.cc:3:10: note: previous definition is here
    void foo() {}
         ^
1 error generated.

This should apply all the way back to C++98, this isn't a C++14 change.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]