help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Struct self pointers turn to void* in gdb


From: Stone
Subject: Struct self pointers turn to void* in gdb
Date: Wed, 08 Dec 2010 15:42:16 -0000
User-agent: G2/1.0

Hi.
I wrote a smart pointer struct (named ptr) as a linked list, like
this:
struct ptr{
    int node;
    ptr *next;
    ptr(){}
    ptr(int _node, ptr *_next){ node=_node; next=_next; }
};
struct list_t{
    ptr *sht;
    int size;
    void push(int node){
        size++;
        sht=new ptr(node,sht);
    }
}shthead[100001], comp[200001], tree[200001];

However, when I debugged the code in gdb, all the ptr*'s turned to
void*.
There is no compile error though I didn't ever know this problem when
coding, and I have to convert the void* to ptr* to view the data in it
in gdb.
I watched the type definition in gdb, below is the output of it:
(gdb) pt ptr
type = struct ptr {
    int node;
    void *next;
  public:
    ptr(void);
    ptr(int, void *);
}

I'm using Linux, 32-bit, gdb 7.1, g++ 4.5.0.
There's no problem if I use g++ 4.4.3, also gdb 7.1.
And my code is compiled without any compilation flags but a -g.
GDB version info:
This GDB was configured as "i686-pc-linux-gnu"

Is there anyone knows the reason for this please?

Stone.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]