Article View: gnu.g++.bug
Article #749Another possible G++ bug?
From: David S. Masterson
Date: Wed, 17 Jan 1990 20:09
Date: Wed, 17 Jan 1990 20:09
61 lines
1568 bytes
1568 bytes
The following test program illustrates what I think is a problem with G++. I
am using G++ 1.36.1 on SunOS 3.5. The problem concerns improper use of the
private data of a parent class by a child class member method. The program
compiles fine and runs fine with the expected result (depending on your line
of thought):
N=3
X=1
---------------- Code follows ----------------
#include <stream.h>
class A {
int x;
public:
A() { x = 1; }
~A() {}
print() { cout << x << "\n"; }
};
class B {
static A* aptr;
public:
B(A* a) { aptr = a; }
~B() {}
};
class C:B {
int n;
public:
C(A* a, int z):(a) { n = z; }
~C() {}
void testfunc();
};
void C::testfunc() {
cout << "N=" << n << "\n";
cout << "X=";
aptr->print();
}
int main()
{
A testa;
C testc(&testa, 3);
testc.testfunc();
}
----------------
--
===================================================================
David Masterson Consilium, Inc.
uunet!cimshop!davidm Mt. View, CA 94043
===================================================================
"If someone thinks they know what I said, then I didn't say it!"
Technical Details
Message-ID:
<CIMSHOP!DAVIDM.90Jan17120916@uunet.UU.NET>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!cimshop!davidmShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: gnu.g++.bug Subject: Another possible G++ bug? Message-ID: <CIMSHOP!DAVIDM.90Jan17120916@uunet.UU.NET> Date: 17 Jan 90 20:09:16 GMT Sender: davidm@cimshop.UUCP Distribution: gnu Organization: Consilium Inc., Mountain View, California. Lines: 61