https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125952
Bug ID: 125952
Summary: ICE with deducing-this function reference type used as
template argument
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/G8d8Tc3xn
Reproducer:
```
int foo() {
return t<auto(&)(const this) -> auto&>;
}
```
Backtrace:
<source>: In function 'int foo()':
<source>:2:26: error: 'this' must be the first specifier in a parameter
declaration
2 | return t<auto(&)(const this) -> auto&>;
| ^~~~
| this ----
<source>:2:26: error: ISO C++ forbids declaration of 'parameter' with no type
[-fpermissive]
<source>:2:20: warning: explicit object member function only available with
'-std=c++23' or '-std=gnu++23' [-Wc++23-extensions]
2 | return t<auto(&)(const this) -> auto&>;
| ^~~~~~~~~~
<source>:2:39: internal compiler error: in grokdeclarator, at cp/decl.cc:15187
2 | return t<auto(&)(const this) -> auto&>;
| ^
0x2a099b8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x29fe5fb internal_error(char const*, ...)
???:0
0xb355b4 fancy_abort(char const*, int, char const*)
???:0
0xc38887 groktypename(cp_decl_specifier_seq*, cp_declarator const*, bool)
???:0
0xd891d3 c_parse_file()
???:0
0xf196f9 c_common_parse_file()
???:0
This seems a crash on invalid and goes back to gcc-16:
https://godbolt.org/z/ehYMssq5f