https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78986
Bug ID: 78986 Summary: template inner classes are not affected by visibility specifiers Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: michele.caini at gmail dot com Target Milestone: --- Consider the following code: class B { struct T {}; }; class D: B { template<typename> struct U: T {}; }; int main() {} GCC accepts it, but it shouldn't for T is private in B and U cannot inherit from it in D. GCC correctly rejects the code below: class B { struct T {}; }; class D: B { struct U: T {}; }; int main() {}