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

            Bug ID: 58993
           Summary: failure to access pointer to protected member method
                    in base from derived class specialization
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cvs at cs dot utoronto.ca

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
    }
};

template <>
struct bar<void> : public base {
    using base::foo;
    foo_type test() { 
        foo();                   // OK
        base::foo();             // OK
        foo_type x = &bar::foo;  // OK
        return &base::foo;       // error
    }
};

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

Compiler output:
protected_base.cpp: In member function ‘void (base::*
bar<void>::test())()const’:
protected_base.cpp:5:10: error: ‘void base::foo() const’ is protected
protected_base.cpp:22:23: error: within this context

Version:
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3

Reply via email to