https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98414
--- Comment #7 from Martin Liška <marxin at gcc dot gnu.org> --- All right, the linker command line is: /home/marxin/Programming/testcases//objdir/./prev-gcc/collect2 -plugin /home/marxin/Programming/testcases//objdir/./prev-gcc/liblto_plugin.so -plugin-opt=/home/marxin/Programming/testcases//objdir/./prev-gcc/lto-wrapper -plugin-opt=-fresolution=cc1plus.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh --eh-frame-hdr -m elf_x86_64 -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cc1plus /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /home/marxin/Programming/testcases//objdir/./prev-gcc/crtbegin.o -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -L./../zlib -L/home/marxin/Programming/testcases//objdir/./prev-gcc -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libsanitizer -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libsanitizer/ubsan -L/home/marxin/Programming/testcases//objdir/prev-x86_64-pc-linux-gnu/libsanitizer/ubsan/.libs -L/lib/../lib64 -L/usr/lib/../lib64 cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/class.o cp/constexpr.o cp/constraint.o cp/coroutines.o cp/cp-gimplify.o cp/cp-objcp-common.o cp/cp-ubsan.o cp/cvt.o cp/cxx-pretty-print.o cp/decl.o cp/decl2.o cp/dump.o cp/error.o cp/except.o cp/expr.o cp/friend.o cp/init.o cp/lambda.o cp/lex.o cp/logic.o cp/mangle.o mapper-resolver.o cp/method.o cp/module.o cp/name-lookup.o cp/optimize.o cp/parser.o cp/pt.o cp/ptree.o cp/rtti.o cp/search.o cp/semantics.o cp/tree.o cp/typeck.o cp/typeck2.o cp/vtable-class-hierarchy.o attribs.o incpath.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o c-family/c-gimplify.o c-family/c-indentation.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-ubsan.o c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o c-family/c-spellcheck.o i386-c.o glibc-c.o cc1plus-checksum.o libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libcody/libcody.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -lmpc -lmpfr -lgmp -lz -Bstatic -lstdc++ -Bdynamic -lm -Bstatic -lubsan -Bdynamic -ldl -lrt -lpthread -lm -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /home/marxin/Programming/testcases//objdir/./prev-gcc/crtend.o /usr/lib/../lib64/crtn.o when I replace -Bstatic -lstdc++ .. -Bstatic -lubsan with: -Bstatic -lubsan -Bstatic -lstdc++ it works.