public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Undefined reference to `__dynamic_cast' when compiling with `-fsantize=vptr -static'
@ 2020-09-01  6:45 eddiekuo
  2020-09-01  7:09 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: eddiekuo @ 2020-09-01  6:45 UTC (permalink / raw)
  To: gcc-help

I compiled the following cpp file with `-fsantize=vptr -static'.

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

int main() { A a; }

There would have the following 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'

There has a same result with gcc11.0.0.
Is it a correct behavior for C++?

Best Regard,
Eddie Kuo
CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Undefined reference to `__dynamic_cast' when compiling with `-fsantize=vptr -static'
  2020-09-01  6:45 Undefined reference to `__dynamic_cast' when compiling with `-fsantize=vptr -static' eddiekuo
@ 2020-09-01  7:09 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-09-01  7:09 UTC (permalink / raw)
  To: eddiekuo; +Cc: gcc-help

On Tue, 1 Sep 2020 at 07:47, <eddiekuo@andestech.com> wrote:
>
> I compiled the following cpp file with `-fsantize=vptr -static'.
>
> struct A {
>   virtual ~A() {};
> };
>
> int main() { A a; }
>
> There would have the following 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'
>
> There has a same result with gcc11.0.0.
> Is it a correct behavior for C++?

No. The problem is that libubsan requires symbols from libstdc++.so
(or libsupc++.a) but comes after it in the link line:

-lstdc++ -lm -lubsan -ldl -lrt -lpthread -lm --start-group -lgcc
-lgcc_eh -lc --end-group

Please report a bug, https://gcc.gnu./org/bugs/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-01  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01  6:45 Undefined reference to `__dynamic_cast' when compiling with `-fsantize=vptr -static' eddiekuo
2020-09-01  7:09 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).