https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78986
Balakrishnan B <balakrishnan.erode at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |balakrishnan.erode at gmail dot co | |m --- Comment #2 from Balakrishnan B <balakrishnan.erode at gmail dot com> --- This has nothing to do with inheritance. If the inner class is template, access specifiers are ignored. Simpler example: class A { struct B1 {}; template<class T> struct B2 {}; }; void foo() { //A::B1 b1; //This doesn't compile (GOOD) A::B2<int> b2; // This compiles (BAD) } Explorer: https://gcc.godbolt.org/z/S0YBPu Bug is present in all versions between GCC 6.1 to trunk. GCC5 and earlier are good.