When compiling the following code I get no error (should get access violation on bar's constructor's access of foo's private foobar() ): # 1 "bug050603.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "bug050603.cc" class foo { public: foo() { }
class bar { public: bar() { foo::foobar(); } }; private: static int foobar(); }; Note that this problems also occurs in 3.3.1 on a Solaris 2.6 Sparc box. I don't have access to any newer compilers to see if it's fixed in latter releases. I found one bug (12226) that sounds related. Output of g++ -v: Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec- prefi x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib -- mandir=/usr/s hare/man --infodir=/usr/share/info --enable- languages=c,ada,c++,d,f77,java,objc, pascal --enable-nls --without-included-gettext --enable-libgcj --with-system- zli b --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable- sj lj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry Thread model: posix gcc version 3.3.3 (cygwin special) -- Summary: Nested class has access to Nestee's private member functions Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mhcox at bluezoosoftware dot com CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901