https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92136
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- We call comp_template_parms with 2 D.2223, 1 d, <<< Unknown tree: template_decl >>> 2 D.2254, 1 d, <<< Unknown tree: template_decl >>> it compares D.2223 to D.2254, then d to d, then the template_decls. When comparing the template decls, we will compare their types: 3289 else if (!same_type_p (TREE_TYPE (parm1), TREE_TYPE (parm2))) 3290 return 0; their types are template_template_parms. So in structural_comptypes we do: 1324 if (!comp_template_parms 1325 (DECL_TEMPLATE_PARMS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t1)), 1326 DECL_TEMPLATE_PARMS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t2)))) 1327 return false; but DECL_TEMPLATE_PARMS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t1)) is 2 D.2223, 1 d, <<< Unknown tree: template_decl >>> and DECL_TEMPLATE_PARMS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t2)) is 2 D.2254, 1 d, <<< Unknown tree: template_decl >>> so we loop.