https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127316
Bug ID: 127316
Summary: [reflection] ICE redeclaring a function whose return
type involves a reflection of a parameter variable
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ensadc at mailnesia dot com
Target Milestone: ---
https://godbolt.org/z/cczW13ofb
====
template<auto>
struct constant_wrapper {};
auto f(int a) -> constant_wrapper<^^a>;
auto f(int a) -> constant_wrapper<^^a>;
====
<source>:5:18: internal compiler error: canonical types differ for identical
types 'constant_wrapper<^^a>' and 'constant_wrapper<^^a>'
5 | auto f(int a) -> constant_wrapper<^^a>;
| ^~~~~~~~~~~~~~~~~~~~~
0x2d1de48 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
???:0
0x2d12a8b internal_error(char const*, ...)
???:0
0xebe9af comptypes(tree_node*, tree_node*, int)
???:0
0xc647bd decls_match(tree_node*, tree_node*, bool)
???:0
0xc97e7d cplus_decl_attributes(tree_node**, tree_node*, int)
???:0
0xc7bef7 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
???:0
0xc7ed18 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0xdd15a3 c_parse_file()
???:0
0xf64c09 c_common_parse_file()
???:0
/cefs/9b/9beb570b65b9542f9deb35d9_gcc-trunk-20260910/bin/../libexec/gcc/x86_64-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -iprefix
/cefs/9b/9beb570b65b9542f9deb35d9_gcc-trunk-20260910/bin/../lib/gcc/x86_64-linux-gnu/17.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++26
-fdiagnostics-color=always -fno-verbose-asm -freflection -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.
====
IIUC, the redeclaration is invalid because the two appearances of `^^a` have
different values (as they are associated with different parameter declarations
-- the source locations are different). GCC 16.2 seems to correctly produce an
error (instead of an ICE).