[llvm-bugs] [Bug 27549] New: Incorrect mangling and linking with C++ language linkage
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Apr 28 05:00:56 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27549
Bug ID: 27549
Summary: Incorrect mangling and linking with C++ language
linkage
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: julien.cretin at trust-in-soft.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
According to my reading of the N3376 draft of the C++11 standard,
"C++" should be the default language linkage. As such, assuming a
well-defined program, I would expect the behavior to be the same
whether a global variable with external linkage is declared as
`extern` or as `extern "C++"`.
N3376:7.5:1: [...] The default language linkage of all function types,
function names, and variable names is C++ language linkage. [...]
% cat m.cpp
extern "C++" int x;
int main(void) { return x; }
% cat x.cpp
extern "C++" int x;
int x = 1;
% clang++ m.cpp x.cpp
/tmp/m-2fcd74.o: In function `main':
m.cpp:(.text+0xe): undefined reference to `x'
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)
% clang++ -c m.cpp; nm m.o
U _Z1x
0000000000000000 T main
% clang++ -c x.cpp; nm x.o
0000000000000000 D x
% g++ m.cpp x.cpp
% g++ -c m.cpp; nm m.o
0000000000000000 T main
U x
% g++ -c x.cpp; nm x.o
0000000000000000 D x
% cat n.cpp
extern int x;
int main(void) { return x; }
% clang++ n.cpp x.cpp
%
The issue seems related to the mangling of global variables with
C++ language linkage, which is not coherent with the mangling of
global variables without language linkage.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160428/ab600818/attachment.html>
More information about the llvm-bugs
mailing list