微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用sanitize = vptr时未定义对__dynamic_cast的引用

如何解决使用sanitize = vptr时未定义对__dynamic_cast的引用

我用vfptr.cpp构建fsanitize=vptrstatic文件中。 它具有有关“未定义对__dynamic_cast的引用”的错误消息。 g ++ 7.4.0和g ++ 11.0.0都有问题。使用sanitizer = vptr是否合理?

vptr.cpp

struct A {
  virtual ~A() {};
};

int main() { A a; }

编译选项

g++ vptr.C -fsanitize=vptr -static

错误消息:

/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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。