Wrong protection using friend declaration
Fengler, Matthias
Matthias.Fengler@dresdner-bank.com
Mon May 31 05:06:00 GMT 1999
Hello,
using a friend declaration within a nested struct causes egcs-1.1.2 to make
all members of the enclosing struct private.
Here is a short example that demonstrates this behavior.
Removing the friend declaration makes the program compile just fine.
This is a plain egcs-1.1.2 on a linux-2.2.2/glibc system.
struct C1
{
C1(){};
struct XX {
friend class C1;
};
};
struct C2 : public C1
{
C2(){};
};
$ g++ -c x.cpp
x.cpp:7: warning: all member functions in class `C1' are private
x.cpp: In method `C2::C2()':
x.cpp:3: `C1::C1()' is private
x.cpp:11: within this context
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
$
Best regards,
Matthias Fengler
Matthias.Fengler@dresdner-bank.com
More information about the Gcc-bugs
mailing list