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

            Bug ID: 82613
           Summary: Cannot access private definitions in base clause of
                    friend class template
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fabian.loeschner at live dot de
  Target Milestone: ---

Affected versions: all up to 8.0.0 20171015

The following code:

    struct Empty {};

    template <typename T>
    struct B;

    struct A
    {
        friend struct B<A>;

    private:
        using BaseForB = Empty;
    };

    template <typename T>
    struct B : T::BaseForB
    {
    };

    int main()
    {
        B<A> test;
        return 0;
    }

leads to the error:

    test.cpp: In instantiation of 'class B<A>':
    test.cpp:21:7: required from here
    test.cpp:15:8: error: 'using BaseForB = class Empty' is private within this
context
     struct B : T::BaseForB
            ^
    test.cpp:11:20: note: declared private here
      using BaseForB = Empty;
                        ^

According to cppreference this should be legal: "The friend itself can also
inherit from private and protected members of this class. (since C++11)".
Furthermore the code works when converting 'B' to a regular class without
template parameters.

Reply via email to