https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104234
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>: https://gcc.gnu.org/g:ab3daffcbf35566d468c3028e48068a481048baf commit r14-6394-gab3daffcbf35566d468c3028e48068a481048baf Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Thu Nov 23 23:15:19 2023 +1100 c++: Clear uninstantiated template friend when instantiating [PR104234] Otherwise attempting to get the originating module declaration ICEs because the DECL_CHAIN of an instantiated friend template is no longer its context. PR c++/104234 PR c++/112580 gcc/cp/ChangeLog: * pt.cc (tsubst_template_decl): Clear DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P. gcc/testsuite/ChangeLog: * g++.dg/modules/pr104234.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>