https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123363
Bug ID: 123363
Summary: ICE: Segmentation fault in finish_call_expr during
template argument parsing with invalid nested
template-id
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: ---
Reproducer: https://godbolt.org/z/9raTseMY5
Compiler crashes with a Segmentation fault when parsing a deeply nested,
syntactically invalid template instantiation where a function call is used as a
template argument, followed by further scope resolution or member access.
Program:
```c
template <typename T>
struct pack_type {
template <typename U>
static void func() {}
};
int main() {
pack_type<int, int>::func<
pack_type<int, int>::func<int>()
>();
}
```
Part of the traceback:
```
internal compiler error: Segmentation fault
17 | pack_type<int, int>::func<pack_type<void (*)(),
int>::func<decltype(fp)>>()
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
0x5da1dc8 internal_error(char const*, ...)
/workspace/install/gcc/src/gcc/gcc/diagnostic-global-context.cc:517
0x273a9a4 crash_signal
/workspace/install/gcc/src/gcc/gcc/toplev.cc:322
0x7ffff79d932f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x15ccc81 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**,
bool, bool, int)
/workspace/install/gcc/src/gcc/gcc/cp/semantics.cc:3522
0x137449f cp_parser_postfix_expression
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:8474
0x137a2ce cp_parser_unary_expression
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:9735
0x137cf99 cp_parser_cast_expression
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:10650
0x137d167 cp_parser_binary_expression
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:10753
0x137f132 cp_parser_assignment_expression
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:11098
0x13a6c1c cp_parser_template_argument
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:20342
0x13a5842 cp_parser_template_argument_list
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:20043
0x13e2640 cp_parser_enclosed_template_argument_list
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:34430
0x13a3728 cp_parser_template_id
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:19574
0x13c3a97 cp_parser_class_name
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:27396
0x136fd48 cp_parser_qualifying_entity
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:7662
0x136e7d1 cp_parser_nested_name_specifier_opt
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:7348
0x136f835 cp_parser_nested_name_specifier
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:7588
0x13bae94 cp_parser_ptr_operator
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:25210
0x13b7cdd cp_parser_declarator
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:24402
0x13bf5ca cp_parser_parameter_declaration
/workspace/install/gcc/src/gcc/gcc/cp/parser.cc:26421
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.
```