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

            Bug ID: 111922
           Summary: GCC: internal compiler error: in decompose, at
                    wide-int.h:1049
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer:
[https://gcc.godbolt.org/z/EoPGKa9r8](https://gcc.godbolt.org/z/EoPGKa9r8)

The code that triggers the crash is somewhat extensive. I've attempted to
minimize it, but the underlying cause seems to be complex. Here's the code:

```c
void f2(void);
struct T1 { int w; };
struct T2 { struct T1 *wi; int a; } v;

static int f1(dpy, wi)
    struct T3 *dpy;
    struct T1 *wi;
{
  (v.a = v.wi->w) || (v.a = v.wi->w);
  f2();
}

static void f3(int wi, int c) {
  int b = f1(0, ~wi);
  fn4(0, 0, v.a);
}

void f5() { f3(0, 0); }
```

Compiling this program with `-O2 -fno-tree-fre` causes GCC to crash.

Some interesting observations about this crash:
1. The crash only occurs when the function `f1` is declared using the old-style
function declaration. If it is converted to the modern style, the crash doesn't
occur.
2. If any statement in the code is commented out, even if it's just half of the
logic or expression inside `f1`, the crash disappears.

The full stack dump:
```
<source>: In function 'f3':
<source>:15:3: warning: implicit declaration of function 'fn4'
[-Wimplicit-function-declaration]
   15 |   fn4(0, 0, v.a);
      |   ^~~
during IPA pass: cp
<source>: At top level:
<source>:18:1: internal compiler error: in decompose, at wide-int.h:1049
   18 | void f5() { f3(0, 0); }
      | ^~~~
0x231f49e internal_error(char const*, ...)
        ???:0
0xa00958 fancy_abort(char const*, int, char const*)
        ???:0
0x103701e range_operator::wi_fold_in_parts(irange&, tree_node*,
generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_storage>
const&, generic_wide_int<wide_int_storage> const&,
generic_wide_int<wide_int_storage> const&) const
        ???:0
0x1037b64 range_operator::fold_range(irange&, tree_node*, irange const&, irange
const&, relation_trio) const
        ???:0
0x1023768 operator_bitwise_not::fold_range(irange&, tree_node*, irange const&,
irange const&, relation_trio) const
        ???: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.
```

Reply via email to