https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81111
Bug ID: 81111 Summary: Cannot build libstdc++ with -fsanitize=undefined Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org Target Milestone: --- Created attachment 41568 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41568&action=edit preprocessed source that causes ICE I tried building libstdc++ using CXXFLAGS="-fsanitize=undefined" and it failed building x86_64-pc-linux-gnu/32/libstdc++-v3/src/c++11/cxx11-locale-inst.o and other files for the 32-bit lib. The same files build OK for 64-bit using -fsanitize=undefined The attached (unreduced) preprocessed source fails using a recent trunk: $ /home/jwakely/src/gcc/build/gcc/cc1plus -fsanitize=undefined -m32 cxx11-locale-inst.ii -quiet In file included from /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/bits/stl_algobase.h:63:0, from /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/bits/char_traits.h:39, from /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/string:40, from /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/bits/locale_classes.h:40, from /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/locale:39, from /home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++11/locale-inst.cc:38, from /home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++11/cxx11-locale-inst.cc:39: /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/ext/numeric_traits.h: In instantiation of ‘const long long unsigned int __gnu_cxx::__numeric_traits_integer<long long unsigned int>::__min’: /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/bits/locale_facets.tcc:474:7: required from ‘_InIter std::num_get<_CharT, _InIter>::_M_extract_int(_InIter, _InIter, std::ios_base&, std::ios_base::iostate&, _ValueT&) const [with _ValueT = long long unsigned int; _CharT = char; _InIter = std::istreambuf_iterator<char, std::char_traits<char> >; std::ios_base::iostate = std::_Ios_Iostate]’ /home/jwakely/src/gcc/gcc/libstdc++-v3/src/c++11/locale-inst.cc:143:27: required from here /home/jwakely/src/gcc/build/x86_64-pc-linux-gnu/32/libstdc++-v3/include/ext/numeric_traits.h:58:67: internal compiler error: Segmentation fault static const _Value __min = __glibcxx_min(_Value); ^ 0xde006f crash_signal /home/jwakely/src/gcc/gcc/gcc/toplev.c:338 0xb2ba10 tree_check(tree_node*, char const*, int, char const*, tree_code) /home/jwakely/src/gcc/gcc/gcc/tree.h:3082 0xb2ba10 gimple_body(tree_node*) /home/jwakely/src/gcc/gcc/gcc/gimple-expr.c:317 0xb538a4 gimple_add_tmp_var(tree_node*) /home/jwakely/src/gcc/gcc/gcc/gimplify.c:753 0xb2c1ea create_tmp_var(tree_node*, char const*) /home/jwakely/src/gcc/gcc/gcc/gimple-expr.c:477 0xe02151 ubsan_encode_value(tree_node*, bool) /home/jwakely/src/gcc/gcc/gcc/ubsan.c:146 0x936fd4 ubsan_instrument_shift(unsigned int, tree_code, tree_node*, tree_node*) /home/jwakely/src/gcc/gcc/gcc/c-family/c-ubsan.c:215 0x8a960d cp_build_binary_op(unsigned int, tree_code, tree_node*, tree_node*, int) /home/jwakely/src/gcc/gcc/gcc/cp/typeck.c:5282 0x671fca build_new_op_1 /home/jwakely/src/gcc/gcc/gcc/cp/call.c:6019 0x6730de build_new_op(unsigned int, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) /home/jwakely/src/gcc/gcc/gcc/cp/call.c:6064 0x89a252 build_x_binary_op(unsigned int, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) /home/jwakely/src/gcc/gcc/gcc/cp/typeck.c:3959 0x810657 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:16921 0x812f16 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:17469 0x806f4e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:16534 0x801db0 regenerate_decl_from_template /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:22419 0x801db0 instantiate_decl(tree_node*, bool, bool) /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:22854 0x72831f maybe_instantiate_decl /home/jwakely/src/gcc/gcc/gcc/cp/decl2.c:4995 0x72af55 mark_used(tree_node*, int) /home/jwakely/src/gcc/gcc/gcc/cp/decl2.c:5094 0x80fd97 tsubst_qualified_id /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:14405 0x8114d9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /home/jwakely/src/gcc/gcc/gcc/cp/pt.c:16946 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.