This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


2187. Protected members and access via qualified-id

Section: 11.8.5  [class.protected]     Status: drafting     Submitter: Hubert Tong     Date: 2015-10-16

The following line in the example in 11.8.5 [class.protected] paragraph 1 is no longer allowed following the change from issue 1873:

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

The example line ought to work, but none of the bullets in 11.8.3 [class.access.base] paragraph 5 apply:

A member m is accessible at the point R when named in class N if

One aproach might be that 11.8.3 [class.access.base] bullet 5.3 should also consider friends of a class P derived from N where P is the type of the object expression (if any) or a base class thereof, and m as a member of P is public, protected, or private.