https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123596
Bug ID: 123596
Summary: ICE in tree check: expected ssa_name, have var_decl in
unlink_stmt_vdef, at tree-ssa-operands.cc:1387 with
-O2 flag
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jirehguo at tju dot edu.cn
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/vb334h5sM
The following valid c++ code crash gcc trunk using -O2 flag.
Goes back to 12.1 with checking.
Code:
```cpp
#include <csetjmp>
#include <functional>
size_t size;
jmp_buf jump_buffer;
template <typename> void f(void *);
int a;
int main() {
auto g = [](int *data) { f<int>(data); };
g(&a);
std::vector(size, setjmp(jump_buffer));
}
```
Stack dump:
```
during GIMPLE pass: ehcleanup
<source>: In function 'int main()':
<source>:11:1: internal compiler error: tree check: expected ssa_name, have
var_decl in unlink_stmt_vdef, at tree-ssa-operands.cc:1387
11 | }
| ^
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
0xa1afc7 tree_check_failed(tree_node const*, char const*, int, char 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.
Compiler returned: 1
```