<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 --- - vtable linkage in key function TU differs between clang and gcc"
   href="https://llvm.org/bugs/show_bug.cgi?id=22992">22992</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>vtable linkage in key function TU differs between clang and gcc
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>yaron.keren@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using gcc version 4.9.1 and clang trunk under Windows 7, the following C++
program creates COMDAT linkage for vtable and typeinfo in gcc but not in clang.

class C {
public:
  virtual void f();
};
void C::f() {}


<span class="quote">>g++ -c v.cpp & dumpbin /headers v.o | grep COMDAT</span >
         COMDAT; sym= __ZTV1C
         COMDAT; sym= __ZTI1C
         COMDAT; sym= __ZTS1C

<span class="quote">>clang++ -target i686-pc-windows-gnu -c v.cpp & dumpbin /headers v.o | grep COMDAT</span >


The difference is probably not related to Windows but the result of
CodeGenModule::getVTableLinkage returning ExternalLinkage for class C. This is
OK as the vtable will not be emitted in other TUs at least with clang. 

However, I am not sure if mixed compiling with clang and gcc-compiled objects
would not bomb in some situations.
There may be a reason why gcc produces weak vtables.

If it makes sense matching gcc behaviour, a patch would be to return
WeakODRLinkage instead of ExternalLinkage.</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>