[Bug c++/58993] incorrectly accept access of protected member method from derived class template

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Nov 5 11:59:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58993

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-05
             Blocks|                            |59002
            Summary|failure to access pointer   |incorrectly accept access
                   |to protected member method  |of protected member method
                   |in base from derived class  |from derived class template
                   |specialization              |
     Ever confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced test, where the base member is private, but the primary template can
still access it

class base {
private:
    int foo() { }
};

template <typename T>
struct bar : public base {
    void test() {
        &base::foo;  // should be rejected
    }
};

template <>
struct bar<void> : public base {
    void test() {
        // &base::foo;  // correctly rejected
    }
};

int main() {
    bar<int>().test();
    bar<void>().test();
}



More information about the Gcc-bugs mailing list