public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5551: g++ 3.0.3 friends and nested classes: fail to compile
@ 2002-01-31 3:06 Konstantin Osipov
0 siblings, 0 replies; only message in thread
From: Konstantin Osipov @ 2002-01-31 3:06 UTC (permalink / raw)
To: gcc-gnats; +Cc: rabid
>Number: 5551
>Category: c++
>Synopsis: nested classess, private constructors, and friends: fail to compile
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Jan 31 03:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Konstantin Osipov
>Release: 3.0.3
>Organization:
>Environment:
glibc 2.2.4, Suse Linux 7.2
System: Linux rabid 2.4.16 #1 Thu Jan 3 22:52:25 MSK 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure
>Description:
Here is the source:
--cut
class Info
{
friend class Creator;
Info();
struct InfoRep;
InfoRep *_rep;
};
struct Info::InfoRep
{
char _data[16];
};
Info::Info()
:_rep(new InfoRep) {}
class Outer
{
friend class Creator;
Outer(Info *info);
struct OuterRep;
OuterRep *_rep;
};
struct Outer::OuterRep
{
Info* _info;
OuterRep(Info *info);
};
Outer::OuterRep::OuterRep(Info *info)
:_info(info) {}
Outer::Outer(Info *info)
:_rep(new OuterRep(info)) {}
class Creator
{
public:
Creator();
};
Creator::Creator()
{
Info info;
Outer outer(&info);
}
int main(int argc, char *argv[])
{
Creator c;
}
--cut
Here is the compiler outputd@rabid:/home/rabid> g++ test.cc
test.cc:10: `struct Info::InfoRep' is private
test.cc:22: within this context
rabid@rabid:/home/rabid>
>How-To-Repeat:
compile it.
>Fix:
If I move line 'friend class Creator;' in class Outer after the declaration
of struct OuterRep everything compiles OK:
--cut
class Outer
{
Outer(Info *info);
struct OuterRep;
OuterRep *_rep;
friend class Creator;
};
--cut
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-01-31 11:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-31 3:06 c++/5551: g++ 3.0.3 friends and nested classes: fail to compile Konstantin Osipov
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).