https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106377
Bug ID: 106377 Summary: A injected-class-name of a private class is not accessible in the member of the derived class. Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xmh970252187 at gmail dot com Target Milestone: --- struct B{}; struct C:private B{ }; struct D:C{ void show(){ struct B b; } }; This example is accepted by GCC but Clang rejects it. The injected-class-name of `B` would be accessible as a private member of `C`, which is not accessible in the member of `D` as per [class.access.base] p4. Further, [class.access] says > Access control is applied uniformly to declarations and expressions. > The interpretation of a given construct is established without regard to > access control. If the interpretation established makes use of inaccessible > members or base classes, the construct is ill-formed.