[llvm-bugs] [Bug 38823] New: 'Undefined reference's with explicit instantiation of template class with virtual members
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Sep 4 07:12:09 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38823
Bug ID: 38823
Summary: 'Undefined reference's with explicit instantiation of
template class with virtual members
Product: OpenMP
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Clang Compiler Support
Assignee: unassignedclangbugs at nondot.org
Reporter: hahnjo at hahnjo.de
CC: llvm-bugs at lists.llvm.org
Created attachment 20836
--> https://bugs.llvm.org/attachment.cgi?id=20836&action=edit
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?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180904/e9e8b752/attachment-0001.html>
More information about the llvm-bugs
mailing list