[Bug c++/36163] Friend declaration confused by namespace/using
--- Comment #4 from redi at gcc dot gnu dot org 2009-10-30 12:14 --- (In reply to comment #2) Isn't ::foo the using'd class from name? No, see 7.3.1.2 [namespace.memdef]/3 - an unqualified friend declaration refers to a member of the innermost enclosing namespace. Names brought into a namespace scope by a using directive are not members of a namespace. If not, how does one befriend a class that comes from a using? You don't, you need to qualify it with the namespace -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36163
[Bug c++/36163] Friend declaration confused by namespace/using
--- Comment #5 from redi at gcc dot gnu dot org 2009-10-30 12:15 --- (In reply to comment #3) I think it is a bug, because the class test is declared at the scope :: A friend declaration specifies a class that belongs to the innermost enclosing namespace scope, outer scopes are not considered. This is not a bug. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36163
[Bug c++/36163] Friend declaration confused by namespace/using
--- Comment #6 from paolo dot carlini at oracle dot com 2009-10-30 12:24 --- Ok, let's close it as invalid. For the record, Comeau 4.3.10.1 Beta2 also rejects it. -- paolo dot carlini at oracle dot com changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36163
[Bug c++/36163] Friend declaration confused by namespace/using
--- Comment #3 from mdjones0978-gccbugs at yahoo dot com 2009-10-30 02:48 --- I think it is a bug, because the class test is declared at the scope :: (before the namespace), then used below. The solution is to explicitly state the fact it is from :: #include assert.h class Test; namespace Boo { class Outer { friend class Test; // replace with ::Test to fix private: int _o; class Inner { friend class Test; // replace with ::Test to fix int _i; }; }; } class Test { public: void DoTest() { Boo::Outer::Inner oi; assert(oi._i == 3); } }; main(int argc, char *argv[]) { Test x; x.DoTest(); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36163
[Bug c++/36163] Friend declaration confused by namespace/using
--- Comment #1 from pinskia at gcc dot gnu dot org 2008-05-06 21:31 --- I don't think this is a bug, the friend class here is really ::foo. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36163
[Bug c++/36163] Friend declaration confused by namespace/using
--- Comment #2 from igodard at pacbell dot net 2008-05-06 21:39 --- Isn't ::foo the using'd class from name? If not, how does one befriend a class that comes from a using? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36163