https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65396
--- Comment #10 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:fe548eb8436f3906e6a3c6e3e8707d24e60ec0fa commit r12-7562-gfe548eb8436f3906e6a3c6e3e8707d24e60ec0fa Author: Patrick Palka <ppa...@redhat.com> Date: Wed Mar 9 08:42:19 2022 -0500 c++: merge default targs for function templates [PR65396] We currently merge default template arguments for class templates, but not for function templates. This patch fixes this by factoring out the argument merging logic in redeclare_class_template into a separate function and using it in duplicate_decls as well. PR c++/65396 gcc/cp/ChangeLog: * cp-tree.h (merge_default_template_args): Declare. * decl.cc (merge_default_template_args): Define, factored out from redeclare_class_template. (duplicate_decls): Use it when merging member function template and free function declarations. * pt.cc (redeclare_class_template): Factor out default argument merging logic into merge_default_template_args. Improve location of a note when there's a template parameter kind mismatch. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/vt-34314.C: Adjust expected location of "redeclared here" note. * g++.dg/template/pr92440.C: Likewise. * g++.old-deja/g++.pt/redecl1.C: Adjust expected location of "redefinition of default argument" error. * g++.dg/template/defarg23.C: New test. * g++.dg/template/defarg23a.C: New test.