[Bug c++/52136] g++ is wrongly propagating "friend class" to the parent class

2014-02-16 Thread jackie.rosen at hushmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

Jackie Rosen  changed:

   What|Removed |Added

 CC||jackie.rosen at hushmail dot 
com

--- Comment #6 from Jackie Rosen  ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.


[Bug c++/52136] g++ is wrongly propagating "friend class" to the parent class

2012-02-06 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

--- Comment #5 from Jonathan Wakely  2012-02-06 
14:24:39 UTC ---
(In reply to comment #4)
> I am not really sure to understand why friend class should impact his parent
> but if g++ respects the standard, why not...

It doesn't "impact his parent"

Read comment 2 again.  To access a protected non-static member you must do so
though an object expression of the derived type, because in the expression
'p->address::m' you only know if 'm' is a member of a 'mailbox' object when 'p'
has type 'mailbox*'

But for a static member that is irrelevant, the static member just exists
independently of any 'mailbox' or 'address' instance, so if mailboxField can
access members of 'mailbox' then it can access the static member, and it
doesn't matter if you refer to it as 'mailbox::parseNext' or
'address::parseNext' because both refer to the exact same entity.


[Bug c++/52136] g++ is wrongly propagating "friend class" to the parent class

2012-02-06 Thread sylvestre at debian dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

--- Comment #4 from Sylvestre Ledru  2012-02-06 
14:08:21 UTC ---
I found this bug (or behavior) while playing with clang. 

I am not really sure to understand why friend class should impact his parent
but if g++ respects the standard, why not...


[Bug c++/52136] g++ is wrongly propagating "friend class" to the parent class

2012-02-06 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #3 from Jonathan Wakely  2012-02-06 
13:56:58 UTC ---
Clang gets this wrong on purpose: http://llvm.org/bugs/show_bug.cgi?id=6840

But G++ implements what the standard says, so INVALID


[Bug c++/52136] g++ is wrongly propagating "friend class" to the parent class

2012-02-06 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

--- Comment #2 from Jonathan Wakely  2012-02-06 
13:50:40 UTC ---
I think G++ is correct here.

[class.protected]p1
An additional access check beyond those described earlier in Clause 11 is
applied when a non-static data member or non-static member function is a
protected member of its naming class (11.2)*

* This additional check does not apply to other members, e.g., static data
members or enumerator member constants.


address::parseNext refers to the same entity as mailbox::parseNext and access
to static members does not involve an object expression, so there is no need
for that access to be done through an object expression of the derived type.


[Bug c++/52136] g++ is wrongly propagating "friend class" to the parent class

2012-02-06 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52136

--- Comment #1 from Jonathan Wakely  2012-02-06 
13:40:08 UTC ---
EDG and Solaris CC also accept it, clang doesn't

The code looks similar to this example from [class.protected] in the standard:

class B {
protected:
int i;
static int j;
};
class D1 : public B {
};
class D2 : public B {
friend void fr(B*,D1*,D2*);
};
void fr(B* pb, D1* p1, D2* p2) {
// ...
p2->i = 3;// OK (access through a D2)
p2->B::i = 4; // OK (access through a D2, even though
  // naming class is B)
// ...
B::j = 5; // OK (because refers to static member)
D2::j = 6;// OK (because refers to static member)
}

Note that the friend of D2 can access non-static members of B through D2* and
can access static members of B directly.