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: unassignedclangb...@nondot.org Reporter: julien.cre...@trust-in-soft.com CC: dgre...@apple.com, llvm-bugs@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs