This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52212] New: friend declaration doesn't see previous friend of same function


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]