This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
default access for class/struct bug?
- From: Michael Matz <matzmich at cs dot tu-berlin dot de>
- To: <gcc at gcc dot gnu dot org>
- Date: Sun, 10 Feb 2002 22:17:08 +0100 (MET)
- Subject: default access for class/struct bug?
Hi,
look at this:
---- snip -----
class Outer {
private:
#if 1
class Inner;
#else
struct Inner;
#endif
Inner *i;
public:
void pub();
};
struct Outer::Inner {
Inner(int i) : mem(i) {}
int mem;
};
void Outer::pub() { i = new Inner(42); }
---- snap -----
Notice how Outer::Inner is once declared with 'class', once with 'struct',
but defined with 'struct' in evry case. The current HEAD thinks:
access.cpp:14: `Outer::Inner::Inner(int)' is private
access.cpp:20: within this context
(when it's changed to #if 0 it of course works). Now the standard says
(if I read it correctly) (11.2), that the default access right of members
depends on the _definition_ not declaration of a class. As this is
changed behaviour (relative to 2.95 and 3.0) I want to confirm, if it's a
bug or a feature?
Ciao,
Michael.