https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108496
--- Comment #2 from CVS 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:4b125d01a5d5e601961419396332b74eea2219bb commit r13-5310-g4b125d01a5d5e601961419396332b74eea2219bb Author: Jason Merrill <ja...@redhat.com> Date: Mon Jan 23 13:33:07 2023 -0500 c++: result location and explicit inst [PR108496] In r13-4469 we started to build the RESULT_DECL in grokdeclarator, while we still know the location of the return type. But in this testcase, we hit that code again when parsing the explicit instantiation, and clobber the DECL_RESULT that was previously used in parsing the function. So, only set DECL_RESULT if it isn't already set. PR c++/108496 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Check whether DECL_RESULT is already set. gcc/testsuite/ChangeLog: * g++.dg/template/explicit-instantiation5.C: New test.