This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58993] failure to access pointer to protected member method in base from derived class specialization
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 05 Nov 2013 11:51:49 +0000
- Subject: [Bug c++/58993] failure to access pointer to protected member method in base from derived class specialization
- Auto-submitted: auto-generated
- References: <bug-58993-4 at http dot gcc dot gnu dot org/bugzilla/>
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;