[cfe-dev] Beginnings of C++ access control (and question about standard)

Tim Northover T.P.Northover at sms.ed.ac.uk
Wed Apr 22 06:18:14 PDT 2009


On Monday 20 Apr 2009 18:22:20 Sebastian Redl wrote:
> Tim Northover wrote:
> >
> > Am I wrong in my interpretation of that particular paragraph; or is that
> > actually forbidden on other grounds (perhaps ambiguity resolution?); or
> > is gcc wrong?
>
> Comeau agrees with GCC, so I'd say they're right. This is because the N
> that is found would be the N within N that Y inherited as private.

I seem to have found similar in an even simpler example where hiding private 
bases doesn't come up:

class N {
protected:
        int m;
};

class P : public N {
  int getX(N n) {
    return n.m;
  }
};

g++ (and comeau) complain that m is protected here, but I just can't see how 
this can fail the condition:

"— m as a member of N is protected, and R occurs [...] or in a member or 
friend of a class P derived from N, where m as a member of P is public, 
private, or protected, or"

I can see why it'd make sense to make some demand that N be a 
pointer/reference that's actually convertible to a P, but I can't see where 
the standard actually does so.

Anyone got any thoughts?

I've put the current version of what I'm working on up at
http://www.maths.ed.ac.uk/~s0677366/access_first.diff
instead of spamming the list with it in case anyone wants to see. 

There's still a few more comments to improve, and this issue to get sorted. 
And I've got various tests scattered around my directory that should be 
integrated. 

The bulk of CheckMemberAccess is probably untested too; I haven't come up with 
a way of getting there without friends which aren't implemented yet. I view it 
more as a scaffold that should be close to doing what I want when I do put 
friends in.

Tim.





More information about the cfe-dev mailing list