This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/58993] failure to access pointer to protected member method in base from derived class specialization


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Chris Studholme from comment #0)
> Sample code:
> 
> class base {
> protected:
>     typedef void (base::*foo_type)() const;
>     void foo() const {}
> };
> 
> template <typename T>
> struct bar : public base {
>     foo_type test() { 
>         return &base::foo;       // OK

The bug is here, this should be an error too (but G++ has lots of bugs with
access checking in templates)

The name foo is a protected member of base, to access it you have to do it via
the derived class, i.e. you should do:

        return &bar::foo;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]