[cfe-dev] [PATCH] Friend class cannot access protected field of parent

Olivier Goffart ogoffart at kde.org
Tue Jun 8 11:29:45 PDT 2010


Le Tuesday 08 June 2010, John McCall a écrit :
> On Jun 8, 2010, at 1:56 AM, Olivier Goffart wrote:
> > Le Tuesday 08 June 2010, John McCall a écrit :
> >> On Jun 8, 2010, at 12:23 AM, Olivier Goffart wrote:
> >>> So you think it is better not to try to make it work, even for the non-
> >>> template case?
> >> 
> >> Yes.  Like I said, I don't think this is an intended feature;  I think
> >> it's a drafting error.  [class.access.base] contains many repetitions
> >> of the phrase "member or friend";  I think someone just wrote "member
> >> or friend" here without really thinking.  I think when they were
> >> drafting the example in [class.protected] they were only thinking about
> >> the effect of the protected access restriction, not whether the member
> >> itself was accessible from the naming class.  I'm willing to consider
> >> evidence in the form of a DR that I'm wrong, but I don't really want to
> >> implement the rule, and I'm not going to implement it as long as it's
> >> undecidable.
> > 
> > Alright.
> > Still, according to the examples in [class.protected], it does not seem
> > to be a simple mistake.
> 
> Right, I acknowledge that.
> 
> For what it's worth, your patch looks pretty good, except (1) I don't see
> how you're dealing with multiple declarations of the target function/record 

I don't know what you mean here, can you elaborate?


> and (2) you're pushing friend decls in template
> definitions, which seems to be inconsistent with what you say g++ does.

Indeed.  That need to be changed.





More information about the cfe-dev mailing list