https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123534
Bug ID: 123534
Summary: [16 Regression] ICE: unexpected expression 'N' of kind
template_parm_index
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/9784xMa5r
The following c++ code crash gcc trunk. But gcc 13,14,15 is fine.
Code:
```cpp
template <bool B> struct ReflectiveNoise {
static void apply() {}
};
int a = 1;
int main() {
auto recursive_clone = []<int N>() {
ReflectiveNoise<(N % a == 0)>::apply();
};
}
```
Stack dump:
```
<source>: In lambda function:
<source>:9:26: internal compiler error: unexpected expression 'N' of kind
template_parm_index
9 | ReflectiveNoise<(N % a == 0)>::apply();
| ~~^~~
0x2924d48 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2919b0b internal_error(char const*, ...)
???:0
0xb9a9e1 maybe_constant_value(tree_node*, tree_node*, mce_value)
???:0
0xe30887 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
???:0
0xb52354 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
???:0
0xe21b12 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
???:0
0xda0f83 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
???:0
0xd8d8dd lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
???:0
0xddd7bc finish_template_type(tree_node*, tree_node*, int)
???:0
0xd573b3 c_parse_file()
???:0
0xec8de9 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
```