https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61327

            Bug ID: 61327
           Summary: Problem with friend template object
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: isak50 at mail dot ru

// Although struct Call_check is a friend for the Comp, the compiler reports  
// that Cnd1::ch() is protected.
#include <iostream>
#include <type_traits>

template <typename... _Break_expression>
struct Call_check;

template <typename _Type>
struct Call_check<_Type>
{
    template <typename _T>
    static void call(_T *trend)
    {
         trend->_Type::ch();
    }
};

class Cnd1
{
protected:
    void ch(void) {std::cout << "hello from Cnd1\n";}
};

class Comp : Cnd1
{
template <typename...>
    friend struct Call_check;
public:
    void check() {Call_check<Cnd1>::call(this);}

};

int main()
{
    Comp cm;
    cm.check();
    return 0;
}

Reply via email to