The accessibility of member of the surrounding class is affected by CWG 45. That means, at least part of the issue has been classified as a defect in the C++98 Standard. (It seems a resolution has been proposed in 2001, so I don't quite understand why it hasn't been fixed in C++03.)
In C++11, the resolution is incorporated, so the paragraph has changed to [class.access.nest]/1:
A nested class is a member and as such has the same access rights as any other member. The members of an enclosing class have no special access to members of a nested class; the usual access rules shall be obeyed. [Example:
class E { int x; class B { }; class I { B b; // OK: E::I can access E::B int y; void f(E* p, int i) { p->x = i; // OK: E::I can access E::x } }; int g(I* p) { return p->y; // error: I::y is private } };
— end example]
(Some) proposed resolutions to defects are implemented in the compilers; note g++ for example specifically says the -std=c++03
flag means
The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect reports.
So it's not obvious what you get when using this flag. However, DRs are "an indication of the intent of the committee", so they can be seen as "bugs" in the Standard, which should be fixed.
VC++2005 seems not to implement the proposed resolution, following the original Standard.