Title
Protected access and pointers to members
Status
nad
Section
11.8.5 [class.protected]
Submitter
Johannes Schaub

Created on 2009-11-24.00:00:00 last changed 173 months ago

Messages

Date: 2010-08-15.00:00:00

Rationale (August, 2010):

Access applies to use of names, so the check must be done at the point at which the pointer-to-member is formed. It is not possible to tell from the pointer to member at runtime what the access was.

Date: 2022-11-20.07:54:16

The restrictions on protected access in 11.8.5 [class.protected] apply only to forming pointers to members and to member access expressions. It should be considered whether to extend these restrictions to pointer-to-member expressions as well. For example,

   struct base {
       protected: int x;
   };

   struct derived : base {
       void foo(base* b) {
          b->x = 123; // not ok
          (b->*(&derived::x)) = 123; // ok?!
       }
   };
History
Date User Action Args
2010-08-23 00:00:00adminsetmessages: + msg2948
2010-08-23 00:00:00adminsetstatus: open -> nad
2009-11-24 00:00:00admincreate