https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96880
Bug ID: 96880 Summary: undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fakepaper56 at gmail dot com Target Milestone: --- I compiled the following code with '-fsanitize=vptr -static'.But I had error message '-fsanitize=vptr -static' struct A { virtual ~A() {}; }; int main() { A a; } Enviorment: gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Compiled option: g++ vptr.i -fsanitize=vptr -static Output error: /usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `isDerivedFromAtOffset(__cxxabiv1::__class_type_info const*, __cxxabiv1::__class_type_info const*, long)': (.text+0x52): undefined reference to `__dynamic_cast' (.text+0x5e): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info' (.text+0x6b): undefined reference to `__dynamic_cast' /usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `findBaseAtOffset(__cxxabiv1::__class_type_info const*, long)': (.text+0x151): undefined reference to `__dynamic_cast' (.text+0x15d): undefined reference to `typeinfo for __cxxabiv1::__vmi_class_type_info' (.text+0x16a): undefined reference to `__dynamic_cast' /usr/lib/gcc/x86_64-linux-gnu/7/libubsan.a(ubsan_type_hash_itanium.o): In function `__ubsan::checkDynamicType(void*, void*, unsigned long)': (.text+0x293): undefined reference to `__dynamic_cast' collect2: error: ld returned 1 exit status