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

            Bug ID: 57593
           Summary: Friendship not extended into friend member-declaration
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: potswa at mac dot com

The access granted by friendship extends into the "member declarations of the
befriended class" (11.3/2). Friend declarations are member-declarations but not
member declarations per se, so the standard is ambiguous. But GCC is
inconsistent.

class c {
    class n {};
    friend struct s;
};

struct s {
    friend class c::n; // OK
    friend c::n g(); // OK
    friend void f() { c::n(); } // Error
};

All three should go the same way, if access is granted per declaration. If the
first two were invalid, private nested classes and related functions would be
impossible to befriend.

Rejection of the third case impedes use of a friend as part of a class
implementation, akin to members, such as the common case of operator <<. Clang
does accept it.

A defect report has been submitted.

Reply via email to