public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* gcc does not allow a private member function to be a friend of another class
@ 2004-07-27 17:23 Denner, Brett
  2004-07-28 19:56 ` James E Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Denner, Brett @ 2004-07-27 17:23 UTC (permalink / raw)
  To: gcc-bugs

In Stroustrup's "The C++ Programming Language," section 11.5, the
following example is given:

=====================================
class List_iterator {
    int* next();
}

class List {
    friend int* List_iterator::next();
}
=====================================

When I compile it with gcc, I get the following output:

=====================================
    test.cpp:2: error: `int* List_iterator::next()' is private
    test.cpp:6: error: within this context
=====================================

Stroustrup's book seems to indicate that this should work.

Here's my output from gcc -v:

=====================================
Reading specs from
/home/brett/local/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/home/brett/local
--enable-languages=c,c++,f77,java
Thread model: posix
gcc version 3.4.1
=====================================

A similar problem occurs if next() is a protected member, but not if
next() is a public member.

Thanks,

Brett


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

* Re: gcc does not allow a private member function to be a friend of another class
  2004-07-27 17:23 gcc does not allow a private member function to be a friend of another class Denner, Brett
@ 2004-07-28 19:56 ` James E Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: James E Wilson @ 2004-07-28 19:56 UTC (permalink / raw)
  To: Denner, Brett; +Cc: gcc-bugs

Denner, Brett wrote:
> In Stroustrup's "The C++ Programming Language," section 11.5, the
> following example is given:

This is documented in the gcc-3.4 release notes.  See
     http://gcc.gnu.org/gcc-3.4/changes.html
scroll down to the C++ section, and then scroll down to the 15th bullet. 
  There is also a pointer to a defect report that makes it clear that 
your testcase is not valid ISO C++.

You probably want to read the rest of the C++ section in the gcc release 
notes also.   Lots of useful info here.

There is an option -fno-access-control that will make this work, but you 
are probably better off fixing your code.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


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

end of thread, other threads:[~2004-07-28 19:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-27 17:23 gcc does not allow a private member function to be a friend of another class Denner, Brett
2004-07-28 19:56 ` James E Wilson

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).