<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Incorrect mangling and linking with C++ language linkage"
   href="https://llvm.org/bugs/show_bug.cgi?id=27549">27549</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect mangling and linking with C++ language linkage
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>julien.cretin@trust-in-soft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>