https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87042
Bug ID: 87042 Summary: UBSAN: poly-int.h:1095:5: runtime error: signed integer overflow: 9223372036854775807 * 8 cannot be represented in type 'long int' Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org Blocks: 63426 Target Milestone: --- Maybe a dup of PR85164, but: $ cat strlen.i const char a[] = {}; b() { '\0' == a[9223372036854775807]; } $ UBSAN_OPTIONS=print_stacktrace=1 ./xgcc -B. strlen.i -O1 strlen.i:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int] 2 | b() { '\0' == a[9223372036854775807]; } | ^ ../../gcc/poly-int.h:1095:5: runtime error: signed integer overflow: 9223372036854775807 * 8 cannot be represented in type 'long int' #0 0xb98b74 in poly_int<1u, poly_result<long, if_nonpoly<int, int, poly_int_traits<int>::is_poly>::type, poly_coeff_pair_traits<long, if_nonpoly<int, int, poly_int_traits<int>::is_poly>::type>::result_kind>::type> operator*<1u, long, int>(poly_int_pod<1u, long> const&, int const&) ../../gcc/poly-int.h:1095 #1 0x23cc1c9 in fully_constant_vn_reference_p(vn_reference_s*) ../../gcc/tree-ssa-sccvn.c:1373 #2 0x23d61f7 in vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**, bool) ../../gcc/tree-ssa-sccvn.c:2540 #3 0x23e1b38 in visit_reference_op_load ../../gcc/tree-ssa-sccvn.c:3798 #4 0x23e34a3 in visit_use ../../gcc/tree-ssa-sccvn.c:4163 #5 0x23e43e2 in process_scc ../../gcc/tree-ssa-sccvn.c:4346 #6 0x23e5812 in extract_and_process_scc_for_name ../../gcc/tree-ssa-sccvn.c:4467 #7 0x23e5bc4 in DFS ../../gcc/tree-ssa-sccvn.c:4517 #8 0x23ea154 in sccvn_dom_walker::before_dom_children(basic_block_def*) ../../gcc/tree-ssa-sccvn.c:4956 #9 0x3ada486 in dom_walker::walk(basic_block_def*) ../../gcc/domwalk.c:353 #10 0x23ead4e in run_scc_vn(vn_lookup_kind) ../../gcc/tree-ssa-sccvn.c:5063 #11 0x23f2aa0 in execute ../../gcc/tree-ssa-sccvn.c:6044 #12 0x1a2a1fc in execute_one_pass(opt_pass*) ../../gcc/passes.c:2446 #13 0x1a2ab8d in execute_pass_list_1 ../../gcc/passes.c:2535 #14 0x1a2ac42 in execute_pass_list_1 ../../gcc/passes.c:2536 #15 0x1a2ace1 in execute_pass_list(function*, opt_pass*) ../../gcc/passes.c:2546 #16 0x1a251da in do_per_function_toporder(void (*)(function*, void*), void*) ../../gcc/passes.c:1688 #17 0x1a2d2b4 in execute_ipa_pass_list(opt_pass*) ../../gcc/passes.c:2894 #18 0xdb3593 in ipa_passes ../../gcc/cgraphunit.c:2407 #19 0xdb434b in symbol_table::compile() ../../gcc/cgraphunit.c:2543 #20 0xdb522e in symbol_table::finalize_compilation_unit() ../../gcc/cgraphunit.c:2788 #21 0x1e2d777 in compile_file ../../gcc/toplev.c:480 #22 0x1e349df in do_compile ../../gcc/toplev.c:2170 #23 0x1e3500d in toplev::main(int, char**) ../../gcc/toplev.c:2305 #24 0x3f49d8a in main ../../gcc/main.c:39 #25 0x7ffff5ca3fea in __libc_start_main ../csu/libc-start.c:308 #26 0x84a529 in _start (/home/marxin/Programming/gcc2/objdir/gcc/cc1+0x84a529) Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426 [Bug 63426] [meta-bug] Issues found with -fsanitize=undefined