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]

C++ Accessibility bugs in egcs


[Resending because I can't find my original mail in the egcs-bugs archives.
My apologies if this will turn up twice.]

Version:
gcc version egcs-2.91.13 980308 (gcc-2.8.0 release)

This example compiles incorrectly in g++. Bla::Init is a private member,
so it should be not accessible in the anonymous namespace. Both KAI C++
and Tendra C++ correctly reject this. The example is lifted [with 
small changes and different Names] from Stroustrup "The C++ Programming
Language" 3rd ed. page 640. 

#include <iostream.h>

class Bla { 
	class Init; 
}; 

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

namespace {
	Bla::Init init; 
}

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]