[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
C++ inherited classes
From: |
Werner LEMBERG |
Subject: |
C++ inherited classes |
Date: |
Wed, 12 Sep 2001 08:46:10 +0200 (CEST) |
This is a question about gdb 4.18 and g++ 2.95.2.
Consider the following small input file:
class node
{
int node_value;
};
class xxx_node : public node
{
int xxx_node_value;
};
int
main(void)
{
node *n;
xxx_node xxx;
n = &xxx;
}
I compiled the program with `g++ -Wall -g -O0 -o zz zz.cc'. Running
`gdb zz' yields
(gdb) tb main
Breakpoint 1 at 0x80483e6: file zz.cc, line 18.
(gdb) r
Starting program: /usr/local/home/ft/a/zz
main () at zz.cc:18
18 n = &xxx;
(gdb) set args
(gdb) n
19 }
(gdb) p n
$1 = (node *) 0xbffff7b0
(gdb) p *n
$2 = {node_value = 1074869784}
(gdb) p *(xxx_node *)n
$3 = {<node> = {node_value = 1074869784}, xxx_node_value = 0}
(gdb) set print object on
(gdb) p n
$4 = (node * ?) 0xbffff7b0
(gdb) p *n
$5 = {node_value = 1074869784}
(gdb) p *(xxx_node *)n
$6 = (node ?) {node_value = 1074869784}
(gdb)
Now my question: Why do I get (node * ?) in $4 and not (xxx_node *)?
And $6 looks like a real bug to me... Am I doing something
fundamentally wrong or am I missing something? Or is my gdb/g++
version too old?
Werner
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- C++ inherited classes,
Werner LEMBERG <=