[cfe-dev] Three code snippets accepted by clang and rejected by g++

Ismail Pazarbasi ismail.pazarbasi at gmail.com
Mon Aug 11 14:43:03 PDT 2014


On Mon, Aug 11, 2014 at 10:31 PM, John McCall <rjmccall at apple.com> wrote:
> On Aug 10, 2014, at 5:26 PM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
>> I'd say the first one is a clang bug.
>
> I agree.  This is poor language design — access should really be granted to all lexically nested code, not just members — but it’s what we’ve got.
>
>> Friends are not transitive, the problem is in the implementation of class.protected restriction inside CheckAccess function.
>>
>>   EffectiveContext EC(S.CurContext);
>>
>> Current context here is class B and that doesn't seem right, added John as he's the author.
>
> That seems wrong.  Are you just speculating?  The current context should be the declaration of ‘int f(B)’ that’s nested within the class.
>
> I believe the correct fix is to change the special case for friend functions in the EffectiveContext constructor, probably by walking to the semantic context instead of the lexical context.  That is, removing the special case completely.  However, presumably that special case was added for a reason.
>
> John.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

I've submitted a patch before, but it needed work, and I forgot about
it (after summer vacation).
Discussion: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130603/080940.html

Ismail




More information about the cfe-dev mailing list