https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109531
--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:2245459c85a3f4cde3d33bf3e4edaff08f3b2404 commit r14-11-g2245459c85a3f4cde3d33bf3e4edaff08f3b2404 Author: Patrick Palka <ppa...@redhat.com> Date: Mon Apr 17 18:52:07 2023 -0400 c++: bound ttp level lowering [PR109531] Here when level lowering the bound ttp TT<typename T::type> via the substitution T=C, we're neglecting to canonicalize (and thereby strip of simple typedefs) the substituted template arguments {A<int>} before determining the new canonical type via hash table lookup. This leads to a hash mismatch ICE for the two equivalent types TT<int> and TT<A<int>> since iterative_hash_template_arg assumes type arguments are already canonicalized. We can fix this by canonicalizing or coercing the substituted arguments directly, but seeing as creation and ordinary substitution of bound ttps both go through lookup_template_class, which in turn performs the desired coercion/canonicalization, it seems preferable to make this code path go through lookup_template_class as well. PR c++/109531 gcc/cp/ChangeLog: * pt.cc (tsubst) <case BOUND_TEMPLATE_TEMPLATE_PARM>: In the level-lowering case just use lookup_template_class to rebuild the bound ttp. gcc/testsuite/ChangeLog: * g++.dg/template/canon-type-20.C: New test. * g++.dg/template/ttp36.C: New test.