Article View: gnu.g++.bug
Article #937incorrect vptr offset, MI?
From: Peter C. McCluskey
Date: Thu, 10 Sep 1992 15:40
Date: Thu, 10 Sep 1992 15:40
52 lines
1713 bytes
1713 bytes
#include <stream.h>
The following produces a bus error at the call n->Foo()
on a Sun 4/60. If "virtual ~A(){}" is removed it will
correctly print 12. I think it is using a function address
from a location after the end of the vtable.
class A
{
public:
virtual ~A(){}
virtual int Foo() { return 10; }
};
class B
{
public:
virtual int Foo() { return 11; }
};
class C : public A,public B
{
public:
virtual int Foo() { return 12; }
};
main()
{
C* n = new C();
cout << n->Foo() << endl;
return 0;
}
kato% g++ -v -c t.cc
Reading specs from /cs/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
/cs/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/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 t.cc /usr/tmp/cca29452.i
GNU CPP version 2.2.2 (sparc)
/cs/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus /usr/tmp/cca29452.i -quiet -dumpbase t.cc -version -o /usr/tmp/cca29452.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
as -o t.o /usr/tmp/cca29452.s
kato% g++ -o t t.o
kato% t
Bus error
I believe this is the relevent assembly output, produced by:
g++ -S -O2 t.cc
ld [%o0+4],%o1
ldsh [%o1+16],%o2
add %o0,4,%o0
ld [%o1+20],%o1
call %o1,0
Technical Details
Message-ID:
<9209102340.AA29505@kato.cs.brown.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.brown.edu!pcmShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.brown.edu!pcm From: pcm@cs.brown.edu (Peter C. McCluskey) Subject: incorrect vptr offset, MI? Message-ID: <9209102340.AA29505@kato.cs.brown.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 10 Sep 1992 15:40:52 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 53