Title
using-declarations and protected access
Status
cd1
Section
11.8.3 [class.access.base]
Submitter
Jason Merrill

Created on 2000-02-28.00:00:00 last changed 196 months ago

Messages

Date: 2001-10-15.00:00:00

[Moved to DR at 10/01 meeting.]

Date: 2001-04-15.00:00:00

Proposed resolution (04/01):

Modify the third bullet of the third change ("A member m is accessible...") in the resolution of issue 9 to read "public, private, or protected" instead of "private or protected."

Date: 2004-09-10.00:00:00

Consider the following example:

  class A {
  protected:
    static void f() {};
  };

  class B : A {
  public:
    using A::f;
    void g() {
      A::f();
    }
  };

The standard says in 11.8.3 [class.access.base] paragraph 4 that the call to A::f is ill-formed:

A member m is accessible when named in class N if
  • m as a member of N is public, or
  • m as a member of N is private, and the reference occurs in a member or friend of class N, or
  • m as a member of N is protected, and the reference occurs in a member or friend of class N, or in a member or friend of a class P derived from N, where m as a member of P is private or protected, or
  • there exists a base class B of N that is accessible at the point of reference, and m is accessible when named in class B.

Here, m is A::f and N is A.

  • f as a member of A is public? No.
  • f as a member of A is private? No.
  • f as a member of A is protected? Yes.
    • reference in a member or friend of A? No.
    • reference in a member or friend of a class derived from A? Yes, B.
      • f as a member of B private or protected? No, public.
  • base of A accessible at point of reference? No.

It seems clear to me that the third bullet should say "public, private or protected".

Steve Adamczyk:The words were written before using-declarations existed, and therefore didn't anticipate this case.

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetstatus: dr -> wp
2002-05-10 00:00:00adminsetmessages: + msg679
2001-11-09 00:00:00adminsetstatus: ready -> dr
2001-05-20 00:00:00adminsetmessages: + msg477
2001-05-20 00:00:00adminsetstatus: drafting -> ready
2000-02-28 00:00:00admincreate