https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115412
Bug ID: 115412 Summary: ICE: canonical types differ for identical types ‘stdis_sametypename fooTtype, U’ and ‘stdis_sameT, U’ Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- ******************************************************************************* The compiler produces an internal error when compiling the provided code with the specified options. The issue involves canonical types differing for identical types during template instantiation. ******************************************************************************* OS and Platform: # uname -a Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ******************************************************************************* # g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /root/gdbtest/gcc/obj/../gcc/configure --prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240509 (experimental) (GCC) ******************************************************************************* Program: # cat main.cpp #include <type_traits> template<typename T> struct foo { using type = T; template< typename U , typename std::enable_if< std::is_same<type, U>::value , int >::type = 0 > void bar(U&&); }; template<typename T> template< typename U , typename std::enable_if< std::is_same<typename foo<T>::type, U>::value , int >::type > void foo<T>::bar(U&&) {} int main() {} ******************************************************************************* Command Lines: # g++ main.cpp -O1 -c -o main.out main.cpp:25:22: internal compiler error: canonical types differ for identical types ‘std::is_same<typename foo<T>::type, U>’ and ‘std::is_same<T, U>’ 25 | void foo<T>::bar(U&&) {} | ^ 0xd499c9 comptypes(tree_node*, tree_node*, int) /root/gdbtest/gcc/obj/../gcc/gcc/cp/typeck.cc:1710 0xd3cf8b cp_tree_equal(tree_node*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/tree.cc:4309 0xc9c3da template_args_equal(tree_node*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:9473 0xc9c105 template_args_equal(tree_node*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:9418 0xc9c105 comp_template_args(tree_node*, tree_node*, tree_node**, tree_node**) /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:9499 0xd49826 structural_comptypes /root/gdbtest/gcc/obj/../gcc/gcc/cp/typeck.cc:1522 0xd4993d comptypes(tree_node*, tree_node*, int) /root/gdbtest/gcc/obj/../gcc/gcc/cp/typeck.cc:1703 0xd49748 structural_comptypes /root/gdbtest/gcc/obj/../gcc/gcc/cp/typeck.cc:1590 0xc99b2f comp_template_parms(tree_node const*, tree_node const*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/pt.cc:3349 0xb8361a check_classfn(tree_node*, tree_node*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl2.cc:878 0xb627e3 grokfndecl /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:11045 0xb69a7b grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**) /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:15114 0xb6d066 start_function(cp_decl_specifier_seq*, cp_declarator const*, tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/decl.cc:18212 0xc83107 cp_parser_function_definition_from_specifiers_and_declarator /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32780 0xc83107 cp_parser_init_declarator /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:23451 0xc8ae60 cp_parser_single_declaration /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:33420 0xc8b01c cp_parser_template_declaration_after_parameters /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32973 0xc8b900 cp_parser_explicit_template_declaration /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:33246 0xc8b2e5 cp_parser_template_declaration_after_export /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:33265 0xc8b2e5 cp_parser_template_declaration_after_parameters /root/gdbtest/gcc/obj/../gcc/gcc/cp/parser.cc:32959 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. ******************************************************************************* Also ICE on trunk, compiler explorer: https://godbolt.org/z/nzKP3Eovr *******************************************************************************