public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22009] New: Friend declaration of a private member function produces error in g++-4.0
@ 2005-06-10 19:21 fjahanian at apple dot com
2005-06-10 19:25 ` [Bug c++/22009] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: fjahanian at apple dot com @ 2005-06-10 19:21 UTC (permalink / raw)
To: gcc-bugs
I think following test case is correct. But g++-4.0 produces a diagnostics. We should be able to declare
a private member function of a class as a friend of another class in order for the member function be
able to access private members of the befriended class.
class FriendTestTo;
class FriendTestFrom
{
private:
void reallySetIt (FriendTestTo* PF);
};
class FriendTestTo
{
private:
int i;
friend void FriendTestFrom::reallySetIt (FriendTestTo*);
};
void FriendTestFrom::reallySetIt (FriendTestTo* PF){ PF->i = 1; };
% g++ -c test.cc
test.cc:6: error: 'void FriendTestFrom::reallySetIt(FriendTestTo*)' is private
test.cc:13: error: within this context
Workaround is to declare class FriendTestFrom as friend of class FriendTestTo.
--
Summary: Friend declaration of a private member function produces
error in g++-4.0
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fjahanian at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: apple-ppc-darwin
GCC host triplet: apple-ppc-darwin
GCC target triplet: apple-ppc-darwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22009
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/22009] Friend declaration of a private member function produces error in g++-4.0
2005-06-10 19:21 [Bug c++/22009] New: Friend declaration of a private member function produces error in g++-4.0 fjahanian at apple dot com
@ 2005-06-10 19:25 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-10 19:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-10 19:24 -------
The code is invalid.
See DR 209 which was closed as not a defect.
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#209
This is a dup of bug 7809 which changed the behavior of GCC to match the standard.
*** This bug has been marked as a duplicate of 7809 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22009
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-10 19:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-10 19:21 [Bug c++/22009] New: Friend declaration of a private member function produces error in g++-4.0 fjahanian at apple dot com
2005-06-10 19:25 ` [Bug c++/22009] " pinskia at gcc dot gnu dot 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).