https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96673
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:de03b82f3ca9103eba3699d1dc91b1d0ee1f16cb commit r11-8018-gde03b82f3ca9103eba3699d1dc91b1d0ee1f16cb Author: Jason Merrill <ja...@redhat.com> Date: Tue Apr 6 15:13:02 2021 -0400 c++: access checking in aggregate initialization [PR96673] We were deferring access checks while parsing B<int>{}, didn't adjust that when we went to instantiate the default member initializer for B::c, deferred access checking for C::C, and then checked it after parsing B<int>{}, back in the main() context which has no access. We need to do the access checks in the class context of the DMI. I tried fixing this in push_to/pop_from_top_level, but that caused several regressions. gcc/cp/ChangeLog: PR c++/96673 * init.c (get_nsdmi): Don't defer access checking. gcc/testsuite/ChangeLog: PR c++/96673 * g++.dg/cpp1y/nsdmi-aggr13.C: New test.