Why does GCC allow inheriting from a private nested class?

c++, g++, gcc, nested-class, private-members

Solution

I've found the answer. Since it's might be useful for others I am posting it here - this is GCC bug 47346.

Problem

Consider the following code: ``` class A { class B {}; }; template <typename C> class D : A::B {}; void f() { D<int> d; } ``` `D<int>` inherits from `A::B` which is a private nested class. I was expecting this to be an error, but GCC accepts this code. Is it a bug in GCC or am I missing something?

Original source