Title
Injection-related errors in access example
Status
tc1
Section
11.8.3 [class.access.base]
Submitter
Steve Adamczyk

Created on 1999-07-16.00:00:00 last changed 262 months ago

Messages

Date: 1999-10-15.00:00:00

Proposed resolution (10/00):

Replace the example in 11.8.3 [class.access.base] paragraph 3 with:

    class B {
    public:
        int mi;                 // nonstatic member
        static int si;          // static member
    };
    class D: private B {
    };
    class DD: public D {
        void f();
    };
    void DD::f() {
        mi = 3;                 // error: mi is private in D
        si = 3;                 // error: si is private in D
        ::B b;
        b.mi = 3;               // OK (b.mi is different from this->mi)
        b.si = 3;               // OK (b.si is different from this->si)
        ::B::si = 3;            // OK
        ::B* bp1 = this;        // error: B is a private base class
        ::B* bp2 = (::B*)this;  // OK with cast
        bp2->mi = 3;            // OK: access through a pointer to B
    }
Date: 2004-09-10.00:00:00

In the example in paragraph 3 of 11.8.3 [class.access.base] , all the references to B in DD::f() should be replaced by ::B. The reason is that the class name B is private in D and thus inaccessible in DD. (The example was probably not updated when class name injection was added.)

History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-11-18 00:00:00adminsetstatus: ready -> dr
2000-05-21 00:00:00adminsetstatus: drafting -> ready
2000-02-23 00:00:00adminsetmessages: + msg227
2000-02-23 00:00:00adminsetstatus: open -> drafting
1999-07-16 00:00:00admincreate