<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 - 'Undefined reference's with explicit instantiation of template class with virtual members"
   href="https://bugs.llvm.org/show_bug.cgi?id=38823">38823</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>'Undefined reference's with explicit instantiation of template class with virtual members
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>Clang Compiler Support
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hahnjo@hahnjo.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20836" name="attach_20836" title="source code detailing the problem">attachment 20836</a> <a href="attachment.cgi?id=20836&action=edit" title="source code detailing the problem">[details]</a></span>
source code detailing the problem

Consider something like the following:
$ cat virtual.cpp
template <typename T>
struct Base {
  virtual ~Base() {}
  virtual void test() const {}
  void offload() {
    #pragma omp target
    {}
  }
};

#ifndef IMPLICIT
template class Base<int>;
#endif

int main(int argc, char *argv[]) {
#ifdef IMPLICIT
  Base<int> b;
#endif

  return 0;
}

$ clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda virtual.cpp
[...]
Undefined reference to '_ZdlPv'
Undefined reference to '_ZTVN10__cxxabiv117__class_type_infoE'
[...]
$ c++filt _ZdlPv
operator delete(void*)
$ c++filt _ZTVN10__cxxabiv117__class_type_infoE
vtable for __cxxabiv1::__class_type_info


Additional notes:
1) When instantiating the template implicitly (-DIMPLICIT), the error goes
away.
2) The vtable for __class_type_info goes away when compiling with -fno-rtti.
3) Commenting out the virtual destructor removes the reference to "operator
delete". I think the destructor is emitted because it is listed in the classes
vtable?</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>