Bug 36625 - gdb and C++ cast
Summary: gdb and C++ cast
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gdb
Version: 7.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Elena Zannoni
QA Contact: Aaron Brown
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-04-19 10:48 UTC by Jakub Jelinek
Modified: 2007-04-18 16:32 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2006-10-18 17:29:27 UTC


Attachments (Terms of Use)

Description Jakub Jelinek 2001-04-19 10:48:27 UTC
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.

Comment 1 Trond Eivind Glomsrxd 2001-04-20 15:10:22 UTC
Verified.

Comment 2 Trond Eivind Glomsrxd 2001-07-30 20:15:42 UTC
Still a problem with CVS gdb.

Comment 3 Trond Eivind Glomsrxd 2001-11-28 23:57:43 UTC
Still a problem with gdb 5.1

Comment 4 Trond Eivind Glomsrxd 2002-05-07 22:22:44 UTC
And 5.2

Comment 5 Bill Nottingham 2006-08-07 20:05:58 UTC
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.


Comment 6 Bill Nottingham 2006-10-18 17:29:27 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.