https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123686
Bug ID: 123686
Summary: [15/16 Regression] ICE in tsubst_requires_expr (tree
check: expected decl_minimal, have error_mark) during
instantiation of invalid auto parameter in
requires-expression
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/q3YsbYsvh
The following c++ code crash gcc trunk with -std=c++20 flag.
Goes back to 15.2 with checking.
Code:
```cpp
auto lambda = [](auto param) {
return requires(auto x) { x; };
}(2);
```
Stack dump:
```
<source>: In lambda function:
<source>:2:24: error: 'auto' parameter not permitted in this context
[-Wtemplate-body]
2 | return requires(auto x) { x; };
| ~~~~~^
<source>: In instantiation of '<lambda(auto:1)> [with auto:1 = int]':
required from here
<source>:3:2:
1 | auto lambda = [](auto param) {
| ~~~~~~~~~~~~~~~~
2 | return requires(auto x) { x; };
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | }(2);
| ~^~~
<source>:2:29: internal compiler error: tree check: expected tree that contains
'decl minimal' structure, have 'error_mark' in tsubst_expr, at cp/pt.cc:22593
2 | return requires(auto x) { x; };
| ^
0x2950b58 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x294591b internal_error(char const*, ...)
???:0
0xa2410a tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
???:0
0xb5c255 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
???:0
0xbb1356 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0xdc7c7d instantiate_decl(tree_node*, bool, bool)
???:0
0xc36863 maybe_instantiate_decl(tree_node*)
???:0
0xc38827 mark_used(tree_node*, int)
???:0
0xb5c0f3 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
???:0
0xe03525 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xd64c43 c_parse_file()
???:0
0xeeed69 c_common_parse_file()
???: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
```