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

            Bug ID: 118344
           Summary: Crash at -O3: internal compiler error: Segmentation
                    fault
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yunboni at smail dot nju.edu.cn
  Target Milestone: ---

This code crashes at -O3:

```c
int d, e, g, h, i, c, j;
static short k;
char o;
static int *p;
static long *a;
int b[0];
int q(int s, int t, int *u, int *v) {
  for (int f = 0; f < s; f++)
    if ((t & v[f]) != u[f])
      return 0;
  return 1;
}
int w(int s, int t) {
  int l[] = {t, t, t, t}, m[] = {e, e, 3, 1};
  int n = q(s, d, l, m);
  return n;
}
int x(unsigned s) {
  unsigned r;
  if (s >= -1)
    return 1;
  r = 10000000;
  while (s > 1 / r)
    r /= 2;
  return g ? 2 : 0;
}
void y() {
  for (;;) {
    b[w(8, *p)] = h;
    for (; a + k; j = o)
      i &= c = x(6) < 0;
  }
}
void main() {}
```

Compiler Explorer: https://godbolt.org/z/6b5d3e6Ej

It seems to be a recent regression.

Crash:

```
during GIMPLE pass: ifcombine
<source>: In function 'y':
<source>:27:6: internal compiler error: Segmentation fault
   27 | void y() {
      |      ^

```

Backtrace:

```
0x261f405 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x2636206 internal_error(char const*, ...)
        ???:0
0x15523ca wi::force_to_size(long*, long const*, unsigned int, unsigned int,
unsigned int, signop)
        ???:0
0xd0549e wide_int_storage::from(generic_wide_int<wide_int_ref_storage<false,
true> > const&, unsigned int, signop)
        ???:0
0xd97152 fold_truth_andor_for_ifcombine(tree_code, tree_node*, unsigned long,
tree_code, tree_node*, tree_node*, unsigned long, tree_code, tree_node*,
tree_node*, tree_node**)
        ???:0
```

Reply via email to