https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122461
Bug ID: 122461
Summary: ICE in make_friend_class due to malformed friend
template template declaration
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: ---
When compiling the following invalid code, the compiler crashes with an
internal compiler error.
Reproducer: https://godbolt.org/z/qGWzrrcv9
Code:
```
template <typename T, int N> class SmallVector {
public:
template <template <int M> class VectorType> friend class VectorType;
};
int main() {
SmallVector<int, 4> vec;
}
```
Output:
```
<source>: In instantiation of 'class SmallVector<int, 4>':
required from here
<source>:7:21:
7 | SmallVector<int, 4> vec;
| ^~~
<source>:1:48: internal compiler error: Segmentation fault
1 | template <typename T, int N> class SmallVector {
| ^
0x28fb988 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x28f077b internal_error(char const*, ...)
???:0
0xc3d884 make_friend_class(tree_node*, tree_node*, bool)
???:0
0xdad3f8 instantiate_class_template(tree_node*)
???:0
0xbdf0e2 start_decl_1(tree_node*, bool)
???:0
0xc040d1 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0xd44da3 c_parse_file()
???:0
0xeb5839 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
```