[Bug c++/45064] New: friends of nested classes don't see outer classes
igodard at pacbell dot net
gcc-bugzilla@gcc.gnu.org
Sun Jul 25 07:29:00 GMT 2010
This code:
class f1 {
class f2 {
class f3;
friend
void bar(f1::f2::f3 arg);
class f3 {};
};
};
void bar(f1::f2::f3 arg) {}
gets you:
foo.cc: In function Âvoid bar(f1::f2::f3)Â:
foo.cc:2: error: Âclass f1::f2Â is private
foo.cc:9: error: within this context
If I change it to:
class f1 {
friend
void bar(f1::f2::f3 arg);
class f2 {
class f3;
class f3 {};
};
};
void bar(f1::f2::f3 arg) {}
I of course get:
foo.cc:4: error: Âf1::f2::f3Â has not been declared
foo.cc: In function Âvoid bar(f1::f2::f3)Â:
foo.cc:5: error: Âclass f1::f2Â is private
foo.cc:10: error: within this context
foo.cc:7: error: Âclass f1::f2::f3Â is private
foo.cc:10: error: within this context
Changing the friend to:
friend
void ::bar(f1::f2::f3 arg);
doesn't change anything.
Seems to me that a friend of an inner class should see anything that class can
see, including outer classes. The friend declaration might be expecting that
bar is a member function of f1, but explicit ::bar to tell the compiler that
it's global doesn't work either.
Is this a bug or have I found another language feature?
--
Summary: friends of nested classes don't see outer classes
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45064
More information about the Gcc-bugs
mailing list