https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112991

            Bug ID: 112991
           Summary: [14 Regression] ICE during GIMPLE pass: ifcvt on
                    p7zip-17.05
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Noticed ICE on current gcc-master when built p7zip-17.05 with
r14-6466-gcd7d0b4cf78926 . Minimized example:

$ cat a.c.c
typedef struct {
  unsigned links[2];
} RMF_unit;
long RMF_recurseListsBound_count;
int RMF_recurseListsBound_tbl, RMF_recurseListsBound_list_head_1;
unsigned RMF_recurseListsBound_list_head_0;
void RMF_recurseListsBound() {
  int list_count = RMF_recurseListsBound_list_head_1;
  long link = RMF_recurseListsBound_list_head_0;
  for (; RMF_recurseListsBound_count;) {
    long next_link =
        ((RMF_unit *)&RMF_recurseListsBound_tbl)[link >> 2].links[0];
    if (link)
      --RMF_recurseListsBound_count;
    link = next_link;
  }
  while (list_count)
    ;
}

$ gcc -std=gnu11 -O2  -c a.c.c -O2 -Wall -Werror
a.c.c: In function 'RMF_recurseListsBound':
a.c.c:12:49: error: array subscript 'RMF_unit[0]' is partly outside array
bounds of 'int[1]' [-Werror=array-bounds=]
   12 |         ((RMF_unit *)&RMF_recurseListsBound_tbl)[link >> 2].links[0];
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
a.c.c:5:5: note: object 'RMF_recurseListsBound_tbl' of size 4
    5 | int RMF_recurseListsBound_tbl, RMF_recurseListsBound_list_head_1;
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
during GIMPLE pass: ifcvt
a.c.c:7:6: internal compiler error: Segmentation fault
    7 | void RMF_recurseListsBound() {
      |      ^~~~~~~~~~~~~~~~~~~~~
0x1e367b4 diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char
const*, __va_list_tag (*) [1], diagnostic_t)
        ???:0
0x1e36f99 internal_error(char const*, ...)
        ???:0
0xd621af crash_signal(int)
        ???:0
0x9d2ad0 tree_single_nonnegative_warnv_p(tree_node*, bool*, int)
        ???:0
0xa3be95 gimple_stmt_nonnegative_warnv_p(gimple*, bool*, int)
        ???:0
0x9d2c45 tree_expr_nonnegative_p(tree_node*)
        ???:0
0x123e667 gimple_simplify_369(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node*, tree_node**, tree_code)
        ???:0
0x13978ff gimple_simplify_RSHIFT_EXPR(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*)
        ???:0
0x139e78d gimple_resimplify2(gimple**, gimple_match_op*, tree_node*
(*)(tree_node*))
        ???:0
0x139f327 gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node* (*)(tree_node*))
        ???:0
0xa30915 gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*),
tree_node* (*)(tree_node*))
        ???:0
0xf3f55c visit_stmt(gimple*, bool) [clone .isra.0]
        ???:0
0xf4000d process_bb(rpo_elim&, basic_block_def*, bool, bool, bool, bool, bool,
bitmap_head*, bool)
        ???:0
0xf417d7 do_rpo_vn_1(function*, edge_def*, bitmap_head*, bool, bool,
vn_lookup_kind)
        ???:0
0xf42a2a do_rpo_vn(function*, edge_def*, bitmap_head*, bool, bool,
vn_lookup_kind)
        ???:0
0xdcdbd6 tree_if_conversion(loop*, vec<gimple*, va_heap, vl_ptr>*)
        ???:0
0xdd030a (anonymous namespace)::pass_if_conversion::execute(function*)
        ???:0
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.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/<<NIX>>/gcc-14.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-14.0.0/libexec/gcc/x86_64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../source/configure --prefix=/<<NIX>>/gcc-14.0.0
--with-gmp-include=/<<NIX>>/gmp-6.3.0-dev/include
--with-gmp-lib=/<<NIX>>/gmp-6.3.0/lib
--with-mpfr-include=/<<NIX>>/mpfr-4.2.1-dev/include
--with-mpfr-lib=/<<NIX>>/mpfr-4.2.1/lib --with-mpc=/<<NIX>>/libmpc-1.3.1
--with-native-system-header-dir=/<<NIX>>/glibc-2.38-27-dev/include
--with-build-sysroot=/ --program-prefix= --enable-lto --disable-libstdcxx-pch
--without-included-gettext --with-system-zlib --enable-checking=release
--enable-static --enable-languages=c,c++ --disable-multilib --enable-plugin
--disable-libcc1 --with-isl=/<<NIX>>/isl-0.20 --disable-bootstrap
--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu
--target=x86_64-unknown-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 99999999 (experimental) (GCC)

Reply via email to