public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96880] New: undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static
@ 2020-09-01  9:05 fakepaper56 at gmail dot com
  2020-09-01  9:29 ` [Bug c++/96880] " jakub at gcc dot gnu.org
  2021-08-17  5:02 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: fakepaper56 at gmail dot com @ 2020-09-01  9:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

* [Bug c++/96880] undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static
  2020-09-01  9:05 [Bug c++/96880] New: undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static fakepaper56 at gmail dot com
@ 2020-09-01  9:29 ` jakub at gcc dot gnu.org
  2021-08-17  5:02 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-09-01  9:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96880

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that lang_specific_driver adds -lstdc++ -lm before the generic
code adds -lubsan.
If you link normally (dynamically), it will work just fine.
Or you can always add -lubsan -lstdc++
Not sure how to fix this properly, the C++ lang_specific_driver doesn't see the
-lubsan option that is only added later on and where exactly in the arguments
-lstdc++ ends up is not something gcc.c can predict.

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

* [Bug c++/96880] undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static
  2020-09-01  9:05 [Bug c++/96880] New: undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static fakepaper56 at gmail dot com
  2020-09-01  9:29 ` [Bug c++/96880] " jakub at gcc dot gnu.org
@ 2021-08-17  5:02 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-17  5:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96880

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-08-17
     Ever confirmed|0                           |1
           Keywords|                            |link-failure

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

end of thread, other threads:[~2021-08-17  5:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01  9:05 [Bug c++/96880] New: undefined reference to `__dynamic_cast' when compiling with -fsanitize=vptr and -static fakepaper56 at gmail dot com
2020-09-01  9:29 ` [Bug c++/96880] " jakub at gcc dot gnu.org
2021-08-17  5:02 ` pinskia at gcc dot gnu.org

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).