public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "herring at lanl dot gov" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106756] Overbroad friendship for nested classes
Date: Fri, 26 Aug 2022 15:34:06 +0000	[thread overview]
Message-ID: <bug-106756-4-SbxXsZlIwW@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106756-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from S. Davis Herring <herring at lanl dot gov> ---
(In reply to Jonathan Wakely from comment #1)
>     "Declaring a class to be a friend implies that private and protected members
>     of the class granting friendship can be named in the base-specifiers and
>     member declarations of the befriended class."
>     
>     A hidden friend is a syntactic member-declaration, but is it a "member
>     declaration"?

That argument doesn't quite apply here: B is the class granting friendship, but
it's A's member being accessed.  To allow this, we'd have to say that B's
friendship gives f access to everything to which B has access, but that would
just be transitive friendship, which is known to be wrong.

That said, one can make a similar argument along the lines of "B is a
member-declaration of A, and so f is part of a member-declaration itself",
which puts us back on the old question of whether it matters whether the friend
is defined inside the class.  Indeed, GCC still rejects the example modified to
use

int f(A::B*) {return A::i;}

but that's an even stronger contradiction with [class.nest]/4 (which uses
"defined within a nested class").

  parent reply	other threads:[~2022-08-26 15:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 15:16 [Bug c++/106756] New: " herring at lanl dot gov
2022-08-26 15:19 ` [Bug c++/106756] " redi at gcc dot gnu.org
2022-08-26 15:34 ` herring at lanl dot gov [this message]
2022-08-29  8:25 ` [Bug c++/106756] [13 Regression] " rguenth at gcc dot gnu.org
2022-09-12 19:27 ` [Bug c++/106756] [CWG1699] " jason at gcc dot gnu.org
2023-04-26  6:56 ` rguenth at gcc dot gnu.org
2023-05-30 12:33 ` ppalka at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org
2024-05-21  9:12 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106756-4-SbxXsZlIwW@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).