This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Member accessibility bugs in egcs/g++


[Resending because earlier tries seem to got lost]

i586-pc-linux-gnulibc1
gcc version egcs-2.91.13 980308 (gcc-2.8.0 release)

This program incorrectly compiles with egcs. Bla::Init is a private member
and shouldn't be accessible in the anonymous namespace. Both Tendra C++ and
KAI C++ correctly reject it. The example is based on code from Stroustrup's
"The C++ Programming Language" , 3rd ed.

#include <iostream.h>

class Bla { 
	class Init; 
}; 

class Bla::Init {
	static int cnt; 
public:
	Init();
	~Init();
}; 

namespace {
	Bla::Init init;  /* Bug! Init is private. */
}

int Bla::Init::cnt = 0; 

Bla::Init::Init()
{
	if (++cnt == 0) cout << "Init" << endl; 
}

Bla::Init::~Init()
{
	if (--cnt == 0) cout << "Ende" << endl; 
}



-Andi






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]