https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117530
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:d034c78c7be613db3c25fddec1dd50222327117b commit r15-9313-gd034c78c7be613db3c25fddec1dd50222327117b Author: Jason Merrill <ja...@redhat.com> Date: Mon Apr 7 14:35:14 2025 -0400 c++: self-dependent alias template [PR117530] Here, instantiating B<short> means instantiating A<short>, which means instantiating B<short>. And then when we go to register the initial instantiation, it conflicts with the inner one. Fixed by checking after tsubst whether there's already something in the hash table. We already did something much like this in tsubst_decl, but that doesn't handle this case. While I was here, I noticed that we had a pop_deferring_access_checks on one early exit but not another, and since I wanted to add yet another I switched to using deferring_access_check_sentinel. PR c++/117530 gcc/cp/ChangeLog: * pt.cc (instantiate_template): Check retrieve_specialization after tsubst. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-uneval27.C: New test.