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").