https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91590
Bug ID: 91590 Summary: ICE in : canonical types differ for identical types std::enable_if<C<D>::ViewConcept< <template-parameter-1-1> >()> and std::enable_if<C<int>::ViewConcept< <template-parameter-1-1> >()> Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: ice-checking Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: jason at gcc dot gnu.org, mpolacek at gcc dot gnu.org Target Milestone: --- It's quite old issue (5.1.0+): $ cat canonical.ii namespace std { template <bool> struct enable_if; } template <typename T> using _t = typename T::type; struct A { using type = int; }; template <template <typename> class> A try_defer_(int); template <template <typename> class C> using defer_ = decltype(try_defer_<C>(0)); template <template <typename> class C> struct F : defer_<C> {}; struct B { template <typename> using invoke = int; }; template <typename...> using and_ = _t<F<B::invoke>>; template <typename> struct C; struct { template <typename Fun> C<Fun> operator()(Fun); } a; template <typename> struct C { template <typename> using ViewConcept = and_<>; template <typename Rng, typename std::enable_if<(ViewConcept<Rng>())>::type> auto m_fn1() -> decltype(a(0)) {} }; struct D; C<D> b; $ g++ canonical.ii -c -std=c++14 canonical.ii: In member function ‘C<int> C< <template-parameter-1-1> >::m_fn1()’: canonical.ii:23:35: warning: no return statement in function returning non-void [-Wreturn-type] 23 | auto m_fn1() -> decltype(a(0)) {} | ^ canonical.ii: In instantiation of ‘struct C<D>’: canonical.ii:26:6: required from here canonical.ii:23:8: internal compiler error: canonical types differ for identical types ‘std::enable_if<C<D>::ViewConcept< <template-parameter-1-1> >()>’ and ‘std::enable_if<C<int>::ViewConcept< <template-parameter-1-1> >()>’ 23 | auto m_fn1() -> decltype(a(0)) {} | ^~~~~ 0xa9cca6 comptypes(tree_node*, tree_node*, int) /home/marxin/Programming/gcc/gcc/cp/typeck.c:1494 0xa9c900 structural_comptypes /home/marxin/Programming/gcc/gcc/cp/typeck.c:1396 0xa2d42a reduce_template_parm_level /home/marxin/Programming/gcc/gcc/cp/pt.c:4280 0xa2b694 tsubst(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.c:14749 0xa2f897 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) /home/marxin/Programming/gcc/gcc/cp/pt.c:19622 0xa22ad7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/marxin/Programming/gcc/gcc/cp/pt.c:17919 0xa2cea3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) /home/marxin/Programming/gcc/gcc/cp/pt.c:11536 0xa2cea3 tsubst_template_arg /home/marxin/Programming/gcc/gcc/cp/pt.c:11547 0xa2cea3 tsubst_template_arg /home/marxin/Programming/gcc/gcc/cp/pt.c:11535 0xa369e2 tsubst_template_args /home/marxin/Programming/gcc/gcc/cp/pt.c:12578 0xa36a7a tsubst_template_args /home/marxin/Programming/gcc/gcc/cp/pt.c:12545 0xa42c4a tsubst_template_decl /home/marxin/Programming/gcc/gcc/cp/pt.c:13283 0xa39899 tsubst_decl /home/marxin/Programming/gcc/gcc/cp/pt.c:13477 0xa2bc3f tsubst(tree_node*, tree_node*, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.c:14383 0xa51f6c instantiate_class_template_1 /home/marxin/Programming/gcc/gcc/cp/pt.c:11224 0xa51f6c instantiate_class_template(tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.c:11529 0xa98fed complete_type(tree_node*) /home/marxin/Programming/gcc/gcc/cp/typeck.c:139 0x939585 start_decl_1(tree_node*, bool) /home/marxin/Programming/gcc/gcc/cp/decl.c:5364 0x9548b7 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) /home/marxin/Programming/gcc/gcc/cp/decl.c:5327 0x9fb45e cp_parser_init_declarator /home/marxin/Programming/gcc/gcc/cp/parser.c:20401 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.