c++/5659: default access for class/struct bug
pcarlini@unitus.it
pcarlini@unitus.it
Mon Feb 11 12:46:00 GMT 2002
>Number: 5659
>Category: c++
>Synopsis: default access for class/struct bug
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 11 12:46:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Michael Matz / Paolo Carlini
>Release: g++ (GCC) 3.1 20020209 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
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 we read it correctly) (11.2), that the default access right of members
depends on the _definition_ not declaration of a class.
>How-To-Repeat:
-gcc3.0.x compiles the testcase just fine, as EDG-based
compilers do.
-In such cases some compilers warn about "inconsistent use
of class/struct keywords".
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list