https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125435
Bug ID: 125435
Summary: ICE in lookup_imported_hidden_friend triggered by
malformed pointer-to-member template parameter in
friend declaration
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: s.kimura.h41104 at gmail dot com
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/qs9bGzvoh
Reproducer:
```
template <typename T> class A {
template <void (A::*p()> class C;
template <void (A::*q)()> friend class C;
};
A<void> a;
```
Backtrace:
<source>: In instantiation of 'class A<void>':
<source>:6:9: required from here
6 | A<void> a;
| ^
<source>:2:34: internal compiler error: in lookup_imported_hidden_friend, at
cp/name-lookup.cc:4787
2 | template <void (A::*p()> class C;
| ^
0x29e1d68 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29d69ab internal_error(char const*, ...)
???:0
0xb2fdca fancy_abort(char const*, int, char const*)
???:0
0xdf0b5f instantiate_class_template(tree_node*)
???:0
0xc0e28d start_decl_1(tree_node*, bool)
???:0
0xc3321d start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0xd831b3 c_parse_file()
???:0
0xf122f9 c_common_parse_file()
???:0
This seems a crash on invalid and goes back to gcc-14.2:
https://godbolt.org/z/heaWP3G8z