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

            Bug ID: 113603
           Summary: [14 Regression] ICE Segfault during GIMPLE pass:
                    strlen at -O3
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at rivosinc dot com
  Target Milestone: ---

Command:
> /scratch/tc-testing/tc-jan-8-trunk/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -O3 red.c -S -freport-bug
during GIMPLE pass: strlen
red.c: In function 'h':
red.c:7:6: internal compiler error: Segmentation fault
    7 | int *h() {
      |      ^
0x12c0303 crash_signal
        ../../../gcc/gcc/toplev.cc:316
0x7fe82a04251f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x14f03cc contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../../gcc/gcc/tree.h:3757
0x14f03cc maybe_invalidate
        ../../../gcc/gcc/tree-ssa-strlen.cc:1361
0x14f0861 do_invalidate
        ../../../gcc/gcc/tree-ssa-strlen.cc:5730
0x150015e strlen_pass::before_dom_children(basic_block_def*)
        ../../../gcc/gcc/tree-ssa-strlen.cc:5780
0x23cb957 dom_walker::walk(basic_block_def*)
        ../../../gcc/gcc/domwalk.cc:311
0x15006e6 printf_strlen_execute
        ../../../gcc/gcc/tree-ssa-strlen.cc:5899
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.

Testcase:
int a, e;
char b;
int *c;
signed char *d;
short f;
char g[3];
int *h() {
  int i = 0;
  for (; i < 3; i++)
    g[i] = 2;
  int j[100][100] = {{}, {4}};
  signed char *k = &g[1];
  do {
    for (;;) {
      if (c)
        break;
      return &a;
    }
    f = 0;
    for (;; f++) {
      b = 0;
      for (; b < 2; b++)
        *c = j[b][f];
      if (e)
        d = k;
      *k = *d;
      if (*c)
        break;
      if (f)
        break;
    }
  } while (f);
  return 0;
}

Godbolt:
https://godbolt.org/z/ax1Tzc3To

Occurs on x86, RISC-V, ARM
Found using a fuzzer.

Reply via email to