Compile without optimization: struct A { int i; virtual ~A(); }; struct B : public A { int j, k; virtual ~B(); }; A::~A() { } B::~B() { } int main(void) { A *x; B y, *z; y.i = 1; y.j = 2; y.k = 3; x = &y; z = (B *)x; } and in gdb: (gdb) b 27; n (gdb) p *z $2 = {<A> = {i = 1, _vptr. = 0x8049838}, j = 2, k = 3} (gdb) p y $3 = {<A> = {i = 1, _vptr. = 0x8049838}, j = 2, k = 3} (gdb) p *(B *)x $4 = {<A> = {i = 1, _vptr. = 0x8049838}, j = 0, k = 0} ^^^^^^^^^^^^ This should IMHO print 2, 3, it is viewing the same memory as y or *z. Tested with our g++, egcs++, g++ 3.1 branch and both with -g and -gdwarf-2, happens everywhere, so it looks like gdb issue.
Verified.
Still a problem with CVS gdb.
Still a problem with gdb 5.1
And 5.2
Red Hat Linux is no longer supported by Red Hat, Inc. If you are still running Red Hat Linux, you are strongly advised to upgrade to a current Fedora Core release or Red Hat Enterprise Linux or comparable. Some information on which option may be right for you is available at http://www.redhat.com/rhel/migrate/redhatlinux/. Red Hat apologizes that these issues have not been resolved yet. We do want to make sure that no important bugs slip through the cracks. Please check if this issue is still present in a current Fedora Core release. If so, please change the product and version to match, and check the box indicating that the requested information has been provided. Note that any bug still open against Red Hat Linux on will be closed as 'CANTFIX' on September 30, 2006. Thanks again for your help.
Red Hat Linux is no longer supported by Red Hat, Inc. If you are still running Red Hat Linux, you are strongly advised to upgrade to a current Fedora Core release or Red Hat Enterprise Linux or comparable. Some information on which option may be right for you is available at http://www.redhat.com/rhel/migrate/redhatlinux/. Closing as CANTFIX.