This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/63769] New: accepts-invalid multiple function definitions in extern "C"
- From: "nlewycky at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 07 Nov 2014 00:10:21 +0000
- Subject: [Bug c++/63769] New: accepts-invalid multiple function definitions in extern "C"
- Auto-submitted: auto-generated
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.