https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105655
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:34970d08c6297e12f3f9117b6ac19fb2de522e24 commit r13-769-g34970d08c6297e12f3f9117b6ac19fb2de522e24 Author: Jason Merrill <ja...@redhat.com> Date: Wed May 25 12:38:58 2022 -0400 c++: CTAD with alias and nested template [PR105655] Here, alias_ctad_tweaks expect tsubst_decl of a FUNCTION_DECL to return a FUNCTION_DECL. A reasonable expectation, but in this case we were replacing the template args of the class-scope deduction guide with equivalent args, so looking in the hash table we found the partial instantiation stored when instantiating A<int>, which is a TEMPLATE_DECL. It's fine for that to be what is stored, but tsubst_function_decl should never return it. PR c++/105655 gcc/cp/ChangeLog: * pt.cc (build_template_decl): Add assert. (tsubst_function_decl): Don't return a template. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias13.C: New test.