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

            Bug ID: 101356
           Summary: The non-public member of a local class cannot be
                    accessed by a friend of the class
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

````
auto fun(){
    void show();
    struct C{
        friend void show();
        private:
          int c;
    };
    return C{};
}
void show(){
   auto o = fun();
   o.c = 0;
}
````
Clang accepts this example while GCC rejects it by reporting an error
diagnosis. 

As per [class.friend#1]

> A friend of a class is a function or class that is given permission to name 
> the >private and protected members of the class. A class specifies its 
> friends, if >any, by way of friend declarations. Such declarations give 
> special access rights >to the friends, but they do not make the nominated 
> friends members of the >befriending class.

Reply via email to