Article View: gnu.g++.bug
Article #362.3.1 privacy problem
From: dong
Date: Tue, 03 Nov 1992 20:28
Date: Tue, 03 Nov 1992 20:28
35 lines
1549 bytes
1549 bytes
This C++ code:
class A{
private:
char *next;
};
class B : public A{
private:
struct foo{
char *next;
} abc;
};
main()
{
class B b;
}
produces this output from g++ -v -c, on a Sun SPARCstation 2 running
SunOS 4.1.3:
Reading specs from /home/glan/lib/gcc-lib/sun4/2.3.1/specs
gcc version 2.3.1
/home/glan/lib/gcc-lib/sun4/2.3.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix tst.cc /usr/tmp/cca02430.i
GNU CPP version 2.3.1 (sparc)
/home/glan/lib/gcc-lib/sun4/2.3.1/cc1plus /usr/tmp/cca02430.i -quiet -dumpbase tst.cc -version -o /usr/tmp/cca02430.s
GNU C++ version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
tst.cc:9: member `next' is private
This code compiled fine under 2.2.2. It seems like foo::next is
inheriting the privacy of A::next. But I think privacy is inherited
only by subclassing, not just by scope; a class member function in A
could have a local variable called next without it somehow inheriting
A::next's privacy.
Technical Details
Message-ID:
<9211032028.AA02512@virtual12.harvard.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!news.encore.com!csar!foxtail!sdd.hp.com!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!das.harvard.edu!dongShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!news.encore.com!csar!foxtail!sdd.hp.com!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!das.harvard.edu!dong From: dong@das.harvard.edu Subject: 2.3.1 privacy problem Message-ID: <9211032028.AA02512@virtual12.harvard.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 3 Nov 1992 20:28:52 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 36