Member accessibility bugs in egcs/g++
Andreas Kleen
ak@muc.de
Mon Mar 16 16:39:00 GMT 1998
[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
More information about the Gcc-bugs
mailing list