https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123329
Bug ID: 123329
Summary: ICE: unexpected expression 'T' of kind
template_parm_index
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: 522024330006 at smail dot nju.edu.cn
Target Milestone: ---
Compiler Explorer:https://godbolt.org/z/q81sz5G34
Program:
```c
template<int N>
struct DeepInst {
static int compute(int x);
};
template<int T>
void loop_func() {
for (int i = 0; i < T; ++i) {
//
DeepInst<T - i>::compute(i);
}
}
int main() {
loop_func<10>();
return 0;
}
```
Traceback:
```
internal compiler error: unexpected expression 'T' of kind template_parm_index
10 | DeepInst<T - i>::compute(i);
| ~~^~~
0x290ee98 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2903c5b internal_error(char const*, ...)
???:0
0xb96611 maybe_constant_value(tree_node*, tree_node*, mce_value)
???:0
0xe2b817 cp_build_binary_op(op_location_t const&, tree_code, tree_node*,
tree_node*, int)
???:0
0xb4dde4 build_new_op(op_location_t const&, tree_code, int, tree_node*,
tree_node*, tree_node*, tree_node*, tree_node**, int)
???:0
0xe1caa2 build_x_binary_op(op_location_t const&, tree_code, tree_node*,
tree_code, tree_node*, tree_code, tree_node*, tree_node**, int)
???:0
0xd9bfa3 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
???:0
0xd888fd lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
???:0
0xdd874c finish_template_type(tree_node*, tree_node*, int)
???:0
0xd523d3 c_parse_file()
???:0
0xec3de9 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
```
The gcc version I used is:
```
Using built-in specs.
COLLECT_GCC=/workspace/install/gcc/install_15.2.0/bin/gcc
COLLECT_LTO_WRAPPER=/workspace/install/gcc/install_15.2.0/libexec/gcc/x86_64-pc-linux-gnu/15.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /workspace/install/gcc/src/gcc/configure --enable-coverage
--enable-checking --disable-multilib --disable-shared --disable-bootstrap
--enable-languages=c,c++ --prefix=/workspace/install/gcc/install_15.2.0
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.2.0 (GCC)
```