http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-06 
13:40:08 UTC ---
EDG and Solaris CC also accept it, clang doesn't

The code looks similar to this example from [class.protected] in the standard:

class B {
protected:
    int i;
    static int j;
};
class D1 : public B {
};
class D2 : public B {
    friend void fr(B*,D1*,D2*);
};
void fr(B* pb, D1* p1, D2* p2) {
    // ...
    p2->i = 3;    // OK (access through a D2)
    p2->B::i = 4; // OK (access through a D2, even though
                  // naming class is B)
    // ...
    B::j = 5;     // OK (because refers to static member)
    D2::j = 6;    // OK (because refers to static member)
}

Note that the friend of D2 can access non-static members of B through D2* and
can access static members of B directly.

Reply via email to