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];
结构 ptr 被用作链表。但是当我在 gdb 中调试代码时,我发现所有的 ptr*'s 都被转换为 void*。
GDB 输出:
(gdb) pt ptr
type = struct ptr {
int node;
void *next;
public:
ptr(void);
ptr(int, void *);
}
然而,在gdb中,如果我将它们转换回ptr*,我仍然可以看到结构体的数据。
请问这是什么原因?
我使用Arch Linux、GNOME、g++ 4.5.0和gdb 7.1。没有任何编译标志,只有一个-g。
This GDB was configured as "i686-pc-linux-gnu"
ptr *
。你使用了哪些编译标志?g++和gdb的版本是什么? - Thomasvoid *
。看起来像是gcc(或gdb)的一个错误。 - Mike Dinsdale