https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121478
Bug ID: 121478
Summary: [ICE] internal compiler error: in fold_convert_loc, at
fold-const.cc:2670
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: njuwy at smail dot nju.edu.cn
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/dx3zfh88v
The crash triggering program (compile with `gcc-16 -O3`):
```
#include <stddef.h>
#include <stdlib.h>
typedef struct {
int data[5];
nullptr_t np;
} container_t;
void process_array(int *arr, size_t len, nullptr_t nullp) {
for (size_t i = 0; i < len; ++i) {
switch (arr[i] % 4) {
case 1:
if (nullp == nullptr) {
arr[i] *= -1;
[[fallthrough]];
}
case 2:
arr[i] = abs(arr[i]);
break;
default:
arr[i] = 0;
}
}
}
int main(void) {
container_t c = {
.data = { -3, 1, 4, 2, 7 },
.np = nullptr
};
process_array(c.data, 5, c.np);
}
```
The crash output:
```
during GIMPLE pass: lsplit
<source>: In function 'process_array':
<source>:7:6: internal compiler error: in fold_convert_loc, at
fold-const.cc:2670
7 | void process_array(int *arr, size_t len, nullptr_t nullp) {
| ^~~~~~~~~~~~~
0x2550a15 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x25462b6 internal_error(char const*, ...)
???:0
0xa04a1c fancy_abort(char const*, int, char const*)
???:0
0x1365852 number_of_iterations_exit(loop*, edge_def*, tree_niter_desc*, bool,
bool, basic_block_def**)
???: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
```