Title
Protected member access from derived class friends
Status
cd4
Section
11.8.3 [class.access.base]
Submitter
Richard Smith

Created on 2014-02-18.00:00:00 last changed 49 months ago

Messages

Date: 2015-05-15.00:00:00

[Moved to DR at the May, 2015 meeting.]

Date: 2014-11-24.00:00:00

Proposed resolution, November, 2014:

Change bullet 5.3 of 11.8.3 [class.access.base] as follows:

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

  • ...

  • m as a member of N is protected, and R 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 public, private, or protected, or

  • there exists...

Date: 2014-11-15.00:00:00

Notes from the November, 2014 meeting:

Although the asymmetry is unfortunate, the difference between a reference in a member function and a reference in a friend is that the member function concretely determines which P is in view, while the friend could be befriended by a class that is a specialization of a class template and thus would require instantiations that would not otherwise occur. CWG thus decided simply to eliminate the friend case.

Date: 2014-06-15.00:00:00

Notes from the June, 2014 meeting:

CWG noted that removing the friend provision would introduce an undesirable asymmetry between member functions of P and its friends. Instead, the intent is to require P to be a complete type at R.

Date: 2014-02-18.00:00:00

According to 11.8.3 [class.access.base] paragraph 5,

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

  • ...

  • m as a member of N is protected, and R 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 public, private, or protected, or

  • ...

The granting of access via class P is troubling. At the least, there should be a restriction that P be visible at R. Alternatively, this portion of the rule could be removed altogether; this provision does not appear to be widely used in existing code and such references can be easily converted to use P instead of N for naming the member.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-11-10 00:00:00adminsetstatus: dr -> drwp
2015-05-25 00:00:00adminsetmessages: + msg6053
2015-05-25 00:00:00adminsetstatus: ready -> dr
2014-11-24 00:00:00adminsetmessages: + msg5154
2014-11-24 00:00:00adminsetmessages: + msg5153
2014-11-24 00:00:00adminsetstatus: drafting -> ready
2014-07-07 00:00:00adminsetmessages: + msg5092
2014-07-07 00:00:00adminsetstatus: open -> drafting
2014-02-18 00:00:00admincreate