<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - LTO results in crash in whole-module-devirtualization with Assertion `hasInitializer() && "GV doesn't have initializer!"' failed."
   href="https://bugs.llvm.org/show_bug.cgi?id=38672">38672</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LTO results in crash in whole-module-devirtualization with Assertion `hasInitializer() && "GV doesn't have initializer!"' failed.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Linker
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>trent.xin.tong@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have a small test case that fails to compile on latest LLVM LTO.

~/llvmtot/build-debug/bin/clang++ main.cpp -c
~/llvmtot/build-debug/bin/clang++ -flto -O3 unknown.cpp -c
~/llvmtot/build-debug/bin/clang++  -flto main.o  unknown.o -o ab -O3

ld: /home/trentxintong/llvmfb/llvm/include/llvm/IR/GlobalVariable.h:142:
llvm::Constant* llvm::GlobalVariable::getInitializer(): Assertion
`hasInitializer() && "GV doesn't have initializer!"' failed.

[~/linkerbug/reduced]$ cat B.hpp 
#include <iostream> 

using namespace std;

template <typename T>
class B {
public:
    B() {}
    virtual void func1() {
      std::cout << "func1 called in class B\n";
    }
};
[~/linkerbug/reduced]$ cat main.cpp 
#include "B.hpp"

void unknown(B<int> *);

int main(int argc, char** argv) {
  B<int> a;
  unknown(&a);
  return 0;
}
[~/linkerbug/reduced]$ cat unknown.cpp 
#include "B.hpp"

__attribute__((optnone))
void unknown2(B<int> *y) {}

void unknown(B<int> *x) {
  B<int> y;
  unknown2(&y);
}</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>