https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100439
--- Comment #12 from Florin Iucha <florin.iucha at amd dot com> --- Actually, it gets even better - no clang needed. Just build GCC 11-20210626 Snapshot and build the example using the Google test recipe: # # Makefile # ALL: bin/test_hello .PHONY: clean CXX=/opt/gcc11-for-tng/bin/g++-11 CXXFLAGS=-m64 -g -std=c++20 -fsanitize=undefined -fno-omit-frame-pointer LDFLAGS=-L/opt/gcc11-for-tng/lib64 -Wl,-rpath,/opt/gcc11-for-tng/lib64 -fsanitize=undefined GOOGLE_TEST_PATH=googletest/googletest GOOGLE_TEST_OBJECTS=obj/gtest.o obj/gtest_main.o obj/gtest-port.o obj/gtest-filepath.o obj/gtest-death-test.o obj/gtest-test-part.o obj/gtest-printers.o obj/test_hello.o: test_hello.cpp $(CXX) $(CXXFLAGS) -o $@ -I$(GOOGLE_TEST_PATH)/include -c $< obj/gtest.o: $(GOOGLE_TEST_PATH)/src/gtest.cc $(CXX) $(CXXFLAGS) -o $@ -I$(GOOGLE_TEST_PATH)/include -I$(GOOGLE_TEST_PATH) -c $< obj/gtest%.o: $(GOOGLE_TEST_PATH)/src/gtest%.cc $(CXX) $(CXXFLAGS) -o $@ -I$(GOOGLE_TEST_PATH)/include -I$(GOOGLE_TEST_PATH) -c $< bin/test_hello: obj/test_hello.o $(GOOGLE_TEST_OBJECTS) $(CXX) -o $@ $(LDFLAGS) $^ -lpthread clean: $(RM) bin/test_hello obj/*.o # # test_hello.cpp # #include <gtest/gtest.h> #include <string> TEST(Hello, World) { ASSERT_EQ(43, std::stoi("42")); } ------ After build: $ ldd bin/test_hello linux-vdso.so.1 (0x00007ffc551ee000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f387908d000) libstdc++.so.6 => /opt/gcc11-for-tng/lib64/libstdc++.so.6 (0x00007f3878ce4000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3878b95000) libubsan.so.1 => /opt/gcc11-for-tng/lib64/libubsan.so.1 (0x00007f387803c000) libgcc_s.so.1 => /opt/gcc11-for-tng/lib64/libgcc_s.so.1 (0x00007f3877e29000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3877c37000) /lib64/ld-linux-x86-64.so.2 (0x00007f387933a000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3877c2f000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3877c24000) $ gdb bin/test_hello ... ... Program received signal SIGSEGV, Segmentation fault. 0x00007ffff6f4f555 in HandleDynamicTypeCacheMiss (Data=0x5555557a49a0, Pointer=140737353637960, Hash=3327454538508686025, Opts=...) at ../../../../gcc/libsanitizer/ubsan/ubsan_handlers_cxx.cpp:36 36 ../../../../gcc/libsanitizer/ubsan/ubsan_handlers_cxx.cpp: No such file or directory. ... (gdb) bt #44921 0x00007ffff6f50516 in __ubsan::checkDynamicType (Object=Object@entry=0x7ffff7f87588 <typeinfo for std::ctype<char>>, Type=0x7ffff7f860b8 <typeinfo for std::type_info>, Hash=8146310091054124745) at ../../../../gcc/libsanitizer/ubsan/ubsan_type_hash_itanium.cpp:233 #44922 0x00007ffff6f4f55a in HandleDynamicTypeCacheMiss (Data=0x5555557a49a0, Pointer=140737353643400, Hash=<optimized out>, Opts=...) at ../../../../gcc/libsanitizer/ubsan/ubsan_handlers_cxx.cpp:36 #44923 0x00007ffff6f4fa92 in __ubsan::__ubsan_handle_dynamic_type_cache_miss (Data=<optimized out>, Pointer=<optimized out>, Hash=<optimized out>) at ../../../../gcc/libsanitizer/ubsan/ubsan_handlers_cxx.cpp:87 #44924 0x000055555567addd in std::type_info::operator== (this=0x7ffff7f87588 <typeinfo for std::ctype<char>>, __arg=...) at /opt/gcc11-for-tng/include/c++/11.1.1/typeinfo:122 #44925 0x00007ffff7c9beec in __cxxabiv1::__vmi_class_type_info::__do_dyncast (this=0x7ffff7f87588 <typeinfo for std::ctype<char>>, src2dst=0, access_path=__cxxabiv1::__class_type_info::__contained_public, dst_type=0x7ffff7f87588 <typeinfo for std::ctype<char>>, obj_ptr=0x7ffff7f93e00 <(anonymous namespace)::ctype_c>, src_type=0x7ffff7f86298 <typeinfo for std::locale::facet>, src_ptr=0x7ffff7f93e00 <(anonymous namespace)::ctype_c>, result=...) at ../../../../gcc/libstdc++-v3/libsupc++/vmi_class_type_info.cc:91 #44926 0x00007ffff7c999e9 in __cxxabiv1::__dynamic_cast (src_ptr=0x7ffff7f93e00 <(anonymous namespace)::ctype_c>, src_type=0x7ffff7f86298 <typeinfo for std::locale::facet>, dst_type=0x7ffff7f87588 <typeinfo for std::ctype<char>>, src2dst=0) at ../../../../gcc/libstdc++-v3/libsupc++/dyncast.cc:74 #44927 0x00007ffff7cdfd6d in std::has_facet<std::ctype<char> > (__loc=...) at /home/fiucha/tools/gcc.objdir/x86_64-linux-gnu/libstdc++-v3/include/bits/locale_classes.tcc:110 #44928 0x00007ffff7cd6fcf in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale (this=this@entry=0x5555557cc988 <std::cout@@GLIBCXX_3.4+8>, __loc=...) at /home/fiucha/tools/gcc.objdir/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_ios.tcc:159 #44929 0x00007ffff7cd7263 in std::basic_ios<char, std::char_traits<char> >::init (this=this@entry=0x5555557cc988 <std::cout@@GLIBCXX_3.4+8>, __sb=__sb@entry=0x7ffff7f92460 <__gnu_internal::buf_cout_sync>) at /home/fiucha/tools/gcc.objdir/x86_64-linux-gnu/libstdc++-v3/include/bits/basic_ios.tcc:132 #44930 0x00007ffff7ce72db in std::basic_ostream<char, std::char_traits<char> >::basic_ostream (__sb=<optimized out>, __vtt_parm=0x0, __in_chrg=1, this=0x5555557cc980 <std::cout@@GLIBCXX_3.4>) at /home/fiucha/tools/gcc.objdir/x86_64-linux-gnu/libstdc++-v3/include/ostream:85 #44931 std::basic_ostream<char, std::char_traits<char> >::basic_ostream (this=0x5555557cc980 <std::cout@@GLIBCXX_3.4>, __sb=0x7ffff7f92460 <__gnu_internal::buf_cout_sync>) at /home/fiucha/tools/gcc.objdir/x86_64-linux-gnu/libstdc++-v3/include/ostream:85 #44932 0x00007ffff7ca39c3 in std::ios_base::Init::Init (this=<optimized out>) at /home/fiucha/tools/gcc/libstdc++-v3/libsupc++/new:175 #44933 std::ios_base::Init::Init (this=<optimized out>) at ../../../../../gcc/libstdc++-v3/src/c++98/ios_init.cc:78 #44934 0x000055555561be74 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /opt/gcc11-for-tng/include/c++/11.1.1/iostream:74 #44935 0x000055555561c121 in _GLOBAL__sub_I__ZN16Hello_World_Test10test_info_E () at test_hello.cpp:8 #44936 0x0000555555708b6d in __libc_csu_init () #44937 0x00007ffff6b66040 in __libc_start_main (main=0x5555556e26a3 <main(int, char**)>, argc=1, argv=0x7fffffffe858, init=0x555555708b20 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe848) at ../csu/libc-start.c:264 #44938 0x000055555561bb3e in _start () Note the depth of the stack trace.