https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118651
Bug ID: 118651 Summary: [15 Regression] ICE: in tree_to_poly_uint64, at tree.cc:3350 with invalid pointer passed to stringops Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zsojka at seznam dot cz Target Milestone: --- Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Created attachment 60273 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60273&action=edit reduced testcase The same can be observed at least with strncat() and memset(). The code is technically valid at compile time, but UB in runtime. Compiler output: $ x86_64-pc-linux-gnu-gcc -O -march=graniterapids-d testcase.c during RTL pass: expand testcase.c: In function 'foo': testcase.c:6:10: internal compiler error: in tree_to_poly_uint64, at tree.cc:3350 6 | return *(V *)__builtin_memmove(&v - 1, 0, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0x2de40a1 internal_error(char const*, ...) /repo/gcc-trunk/gcc/diagnostic-global-context.cc:517 0xef861d fancy_abort(char const*, int, char const*) /repo/gcc-trunk/gcc/diagnostic.cc:1722 0x902780 tree_to_poly_uint64(tree_node const*) /repo/gcc-trunk/gcc/tree.cc:3350 0x902780 tree_to_poly_uint64(tree_node const*) /repo/gcc-trunk/gcc/tree.cc:3348 0x16f69d1 bit_field_offset(tree_node const*) /repo/gcc-trunk/gcc/tree.h:5719 0x16f69d1 bit_field_ref_in_bounds_p /repo/gcc-trunk/gcc/tree-eh.cc:2662 0x16f69d1 tree_could_trap_p(tree_node*) /repo/gcc-trunk/gcc/tree-eh.cc:2715 0x11cbf47 set_mem_attributes_minus_bitpos(rtx_def*, tree_node*, int, poly_int<1u, long>) /repo/gcc-trunk/gcc/emit-rtl.cc:2047 0x12060fc expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /repo/gcc-trunk/gcc/expr.cc:12381 0x1206e69 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /repo/gcc-trunk/gcc/expr.cc:9521 0x1206e69 expand_expr(tree_node*, rtx_def*, machine_mode, expand_modifier) /repo/gcc-trunk/gcc/expr.h:323 0x1206e69 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /repo/gcc-trunk/gcc/expr.cc:11811 0x12097d5 expand_expr_real_gassign(gassign*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /repo/gcc-trunk/gcc/expr.cc:11190 0x12088c3 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /repo/gcc-trunk/gcc/expr.cc:11368 0x10c71b2 expand_expr(tree_node*, rtx_def*, machine_mode, expand_modifier) /repo/gcc-trunk/gcc/expr.h:323 0x10c71b2 expand_return /repo/gcc-trunk/gcc/cfgexpand.cc:4146 0x10c71b2 expand_gimple_stmt_1 /repo/gcc-trunk/gcc/cfgexpand.cc:4255 0x10c71b2 expand_gimple_stmt /repo/gcc-trunk/gcc/cfgexpand.cc:4364 0x10c786f expand_gimple_basic_block /repo/gcc-trunk/gcc/cfgexpand.cc:6427 0x10ca336 execute /repo/gcc-trunk/gcc/cfgexpand.cc:7176 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. $ x86_64-pc-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-20250125022813-r15-7205-gd0acb7b2b26d4f-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --disable-bootstrap --with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld --with-as=/usr/bin/x86_64-pc-linux-gnu-as --enable-libsanitizer --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-20250125022813-r15-7205-gd0acb7b2b26d4f-checking-yes-rtl-df-extra-nobootstrap-amd64 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 15.0.1 20250125 (experimental) (GCC)