Why does GCC allow inheritance of a nested private class?

advertisements

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?


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