https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124603
Bug ID: 124603
Summary: [16 Regression] ICE in retrieve_specialization, at
cp/pt.cc:1285
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: alexey.saldyrkine at gmail dot com
Target Milestone: ---
ICE occurs when using gcc trunk.
Works fine with gcc 15.
godbolt: https://godbolt.org/z/hxTK9M1rr
```
template <typename Key>
struct Reader;
template<typename K>
auto get(Reader<K>);
template <typename Key>
struct Reader
{
friend auto get<>(Reader<Key>);
};
template <typename Key>
struct Writer
{
template<typename K>
friend auto get(Reader<K>){return 1;};
};
int main()
{
(void)Writer<char>{};
get(Reader<int>{});
}
```
Error:
```
<source>: In instantiation of 'struct Reader<int>':
<source>:23:21: required from here
23 | get(Reader<int>{});
| ^
<source>:10:17: internal compiler error: in retrieve_specialization, at
cp/pt.cc:1285
10 | friend auto get<>(Reader<Key>);
| ^~~~~
0x2967de8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x295ca2b internal_error(char const*, ...)
???:0
0xb22cf4 fancy_abort(char const*, int, char const*)
???:0
0xdc3a15 instantiate_template(tree_node*, tree_node*, int)
???:0
0xdd9c0b instantiate_class_template(tree_node*)
???:0
0xe0ac76 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
???:0
0xd6f583 c_parse_file()
???:0
0xef9b29 c_common_parse_file()
???:0
/cefs/a5/a50a924916235be8607ebc6b_gcc-trunk-20260322/bin/../libexec/gcc/x86_64-linux-gnu/16.0.1/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/a5/a50a924916235be8607ebc6b_gcc-trunk-20260322/bin/../lib/gcc/x86_64-linux-gnu/16.0.1/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -fdiagnostics-color=always
-fno-verbose-asm -o /app/output.s
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
```