public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/45917] New: Friend of friend is allowed the access to the private type through the template
@ 2010-10-06 21:20 yuri at tsoft dot com
  2010-10-06 21:40 ` [Bug c++/45917] " redi at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: yuri at tsoft dot com @ 2010-10-06 21:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45917

           Summary: Friend of friend is allowed the access to the private
                    type through the template
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: yuri@tsoft.com


testcase below has struct R as private in class F.
class F declares class Q a friend, allowing it to see it's private members.
But operator<< is friend in Q, not in F.
Why is it allowed for operator<< to instantiate list<R> but not R r? This is a
bug.

--- testcase ---
#include <list>
#include <ostream>
using namespace std;

class F {
private:
  struct R {
  }; // R
  friend class Q;
  class Q {
    list<R> l;
    friend ostream& operator<<(ostream &os, const Q &q) {
      // R r; // this breaks!
      for (list<R>::const_iterator it = q.l.begin(); it != q.l.end(); it++) {
// this doesn't break! Why?
      }
      return os;
    }
  }; // Q
}; // F


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-04-01 21:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-06 21:20 [Bug c++/45917] New: Friend of friend is allowed the access to the private type through the template yuri at tsoft dot com
2010-10-06 21:40 ` [Bug c++/45917] " redi at gcc dot gnu.org
2010-10-06 21:48 ` [Bug c++/45917] inaccessible types allowed as template argument in nested-name-specifier redi at gcc dot gnu.org
2013-03-14 21:15 ` jason at gcc dot gnu.org
2013-03-14 21:40 ` jason at gcc dot gnu.org
2013-03-17  2:40 ` jason at gcc dot gnu.org
2013-03-22 11:18 ` paolo.carlini at oracle dot com
2013-04-01 21:04 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).