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

            Bug ID: 112502
           Summary: GCC: 14: internal compiler error: in
                    get_predictor_value, at predict.cc:2695
           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/WP94TWqj5

When compiling this program with `gcc-14 -O1`, gcc crashes:
```
int global;

void foo(int a, short b) {
  if (__builtin_expect_with_probability(a, 1, -2.0f) >
      __builtin_expect_with_probability(b, 0, 0.8f))
    global++;
}
```

Based on the diagnostic error messages, the cause of the crash appears to be
the invalid argument `-2.0f` passed into the
`__builtin_expect_with_probability` function. But after removing the `if`, as
this program, the crash disappears:
```
int global;

void foo(int a, short b) {
  __builtin_expect_with_probability(a, 1, -2.0f) >
      __builtin_expect_with_probability(b, 0, 0.8f);
  global++;
}
```

The crash output:
```
<source>: In function 'foo':
<source>:4:7: error: probability '-2.0e+0' is outside the range [0.0, 1.0]
    4 |   if (__builtin_expect_with_probability(a, 1, -2.0f) >
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
during GIMPLE pass: profile_estimate
<source>:7:1: internal compiler error: in get_predictor_value, at
predict.cc:2695
    7 | }
      | ^
0x238b15e internal_error(char const*, ...)
        ???:0
0xa11270 fancy_abort(char const*, int, char const*)
        ???:0
0x1019629 tree_estimate_probability(bool)
        ???: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.
Compiler returned: 1
```
  • [Bug c/112502] New: GCC: 14... 141242068 at smail dot nju.edu.cn via Gcc-bugs

Reply via email to