public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101356] New: The non-public member of a local class cannot be accessed by a friend of the class
@ 2021-07-07  2:39 xmh970252187 at gmail dot com
  2021-08-02 15:35 ` [Bug c++/101356] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: xmh970252187 at gmail dot com @ 2021-07-07  2:39 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-23 18:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07  2:39 [Bug c++/101356] New: The non-public member of a local class cannot be accessed by a friend of the class xmh970252187 at gmail dot com
2021-08-02 15:35 ` [Bug c++/101356] " pinskia at gcc dot gnu.org
2021-12-13 15:58 ` pinskia at gcc dot gnu.org
2023-08-23 18:14 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).