https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109480
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:681ba2f7681f295a102cd63ffd5ce2b86a5f706e commit r14-557-g681ba2f7681f295a102cd63ffd5ce2b86a5f706e Author: Patrick Palka <ppa...@redhat.com> Date: Sun May 7 10:24:52 2023 -0400 c++: non-dep init folding and access checking [PR109480] enforce_access currently checks processing_template_decl to decide whether to defer the given access check until instantiation time. But using this flag is unreliable because it gets cleared during e.g. non-dependent initializer folding, and so can lead to premature access check failures as in the below testcase. It seems better to check current_template_parms instead. PR c++/109480 gcc/cp/ChangeLog: * semantics.cc (enforce_access): Check current_template_parms instead of processing_template_decl when deciding whether to defer the access check. gcc/testsuite/ChangeLog: * g++.dg/template/non-dependent25a.C: New test.