https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120555
--- Comment #3 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:8d204f2a536f7253e4251aca7bc12af524800b4c commit r16-1272-g8d204f2a536f7253e4251aca7bc12af524800b4c Author: Jason Merrill <ja...@redhat.com> Date: Fri Jun 6 10:26:28 2025 -0400 c++: recursive template with deduced return [PR120555] Here since r15-4120 we were prematurely complaining about the use of func within its own definiton, which is fine at instantiation time. So don't require this for function templates that are currently being defined. But keep the error for instantiations of templates that are not currently being defined, which we similarly did not diagnose before r15-4120 but other implementations do. Both of these follow the general principle from [temp.res.general]/6 that we only error in a template body if no instatiation could be well-formed. Also remove a redundant call to require_deduced_type. PR c++/120555 gcc/cp/ChangeLog: * decl2.cc (fn_being_defined, fn_template_being_defined): New. (mark_used): Check fn_template_being_defined. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if39.C: New test.