struct Base
{
  protected:
    typedef void (Base::*fnc)() const;
    void fnc_to_expose() const {}
};

template <typename T>
struct Derived : public Base
{
    fnc expose() { return &Base::fnc_to_expose; }
    fnc expose2() { return &Derived<T>::fnc_to_expose; }
};

void foo(void)
{
  Derived<int>  i;
  i.expose();
  i.expose2();
}

does accept i.expose() which is invalid as can be seen by either using
a specialized version of Derived or using a non-template Derived.  It
should tell us

 ex.cc: In member function 'void (Base::* Class::expose())()const':
 ex.cc:13: error: 'void Base::fnc_to_expose() const' is protected
 ex.cc:54: error: within this context

as it does for those alternatives.

-- 
           Summary: Access control bug for base class of templates
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to