default access for class/struct bug?

Paolo Carlini pcarlini@unitus.it
Sun Feb 10 17:44:00 GMT 2002


Michael Matz wrote:

> 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); }

Hi. I'm not a language lawyer but it looks like the EDG front end gives you
reason: it compiles the testcase in "strict" mode too...

> (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.

... however I cannot find explicit reference to definition vs declaration in
11.2, which seems to me more about member access control in inheritance. Could
you please be more specific?
(I'm tempted to suggest submitting a regular GNATS report, to be sure)

Ciao, Paolo.




More information about the Gcc mailing list