https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105761
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:2843bfa21073dd1ac222540e189e8bcf40afc2c0 commit r12-8456-g2843bfa21073dd1ac222540e189e8bcf40afc2c0 Author: Jason Merrill <ja...@redhat.com> Date: Fri Jun 3 12:35:12 2022 -0400 c++: redeclared hidden friend [PR105761] Here, when we see the second declaration of f we match it with the first one, copy over DECL_TEMPLATE_INFO, and then try to use it when parsing the definition, leading to confusion. PR c++/105761 gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Don't copy DECL_TEMPLATE_INFO from a hidden friend. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/auto-fn64.C: New test.