This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Confusing about the accessibility of the base class
- From: zhang qingshan <steven dot zhang54373 at gmail dot com>
- To: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 11 May 2011 18:04:56 +0800
- Subject: Confusing about the accessibility of the base class
Hi, guys,
I test the following testcase with GCC 4.6
struct A {
private:
struct Patch {};
};
#ifdef TMPL
template <int x>
#endif
struct X : private A
{
void f () {
typedef A::Patch Patch;
}
};
int main()
{
#ifdef TMPL
X<1> d;
#else
X d;
#endif
d.f();
}
If TMPL is not defined, get the error message:
/data/a.cpp: In member function 'void X::f()':
/data/a.cpp:3:11: error: 'struct A::Patch' is private
/data/a.cpp:12:24: error: within this context
which makes sense, as struct Patch is the private member of struct A.
But if TMPL is defined, GCC compiles it clean. This confuses me.