https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123602
Bug ID: 123602
Summary: ICE: SSA corruption during RTL pass: expand with -O2
and -std=c++20 flag
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jirehguo at tju dot edu.cn
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/G7x58WzKT
The following c++ code crash gcc trunk with -O2 flag.
Goes back to gcc 8.1 with -O2 flag.
Code:
```cpp
#include <csetjmp>
#include <vector>
int ARRAY_SIZE;
jmp_buf jump_buffer;
template <typename> struct Inline { static void apply(int); };
struct CleanupContext {
jmp_buf env;
};
int main() {
{
for (int i; i;) {
CleanupContext context;
if (setjmp(context.env)) {
asm("memory");
std::vector<int> arr(ARRAY_SIZE, 1);
for (int j = 3; j; ++j) {
int i10 = arr[j - 1];
if (setjmp(jump_buffer))
;
Inline<int>::apply(i10);
}
}
}
}
}
```
Stack dump:
```
Unable to coalesce ssa_names 6 and 8 which are marked as MUST COALESCE.
j_6(ab) and j_8(ab)
during RTL pass: expand
<source>: In function 'int main()':
<source>:9:5: internal compiler error: SSA corruption
9 | int main() {
| ^~~~
0x292a498 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x291f25b internal_error(char const*, ...)
???:0
0x167a424 coalesce_ssa_name(_var_map*)
???:0
0x1601f34 rewrite_out_of_ssa(ssaexpand*)
???: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
```