https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97171
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathan Sidwell <nat...@gcc.gnu.org>: https://gcc.gnu.org/g:13f7c5d504b5fe6c233f2e68acd10bd4fc9007ac commit r11-3398-g13f7c5d504b5fe6c233f2e68acd10bd4fc9007ac Author: Nathan Sidwell <nat...@acm.org> Date: Wed Sep 23 07:01:10 2020 -0700 c++: dependent local extern decl ICE [PR97171] I'd missed the piece of substutution for the uses of a local extern decl. Just grab the local specialization. We need to do this regardless of dependentness because we always cloned the local extern. PR c++/97171 gcc/cp/ * pt.c (tsubst_copy) [FUNCTION_DECL,VAR_DECL]: Retrieve local specialization for DECL_LOCAL_P decls. gcc/testsuite/ * g++.dg/template/local10.C: New.