C++ Accessibility bugs in egcs
ak@muc.de
ak@muc.de
Sat Mar 14 18:47:00 GMT 1998
[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
More information about the Gcc-bugs
mailing list