http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52212
Bug #: 52212 Summary: friend declaration doesn't see previous friend of same function Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: igod...@pacbell.net This code: class D { class E{ class F{}; friend void foo1(D::E::F& q); }; friend void foo1(D::E::F& q); }; void foo1(D::E::F& q) {} int main(int argc, char** argv) { return 0; } gets you: foo.cc:3:9: error: âclass D::E::Fâ is private foo.cc:6:26: error: within this context Note that the same function was earlier made a friend of class E, and so can see F. If you leave out the second friending, you get: foo.cc: In function âvoid foo1(D::E::F&)â: foo.cc:2:8: error: âclass D::Eâ is private foo.cc:9:21: error: within this context which is correct; foo1 cannot see E without the second friend. But with both friends foo1 should see everybody.