[cfe-dev] Three code snippets accepted by clang and rejected by g++
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.
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
I've submitted a patch before, but it needed work, and I forgot about
it (after summer vacation).
More information about the cfe-dev