This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52212] New: friend declaration doesn't see previous friend of same function
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 12 Feb 2012 07:34:44 +0000
- Subject: [Bug c++/52212] New: friend declaration doesn't see previous friend of same function
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: igodard@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.