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 *全部转换为void *。
GDB输出:C++:为什么一个结构的自指针自动改变到void *
(gdb) pt ptr
type = struct ptr {
int node;
void *next;
public:
ptr(void);
ptr(int, void *);
}
不过,我仍然可以看到该结构的数据,如果我隐蔽他们回到PTR *在gdb。
请问这是什么原因?
我使用的是Arch Linux,GNOME,g ++ 4.5.0,gdb 7.1。没有任何编译标志,但是-g。
This GDB was configured as "i686-pc-linux-gnu"
它在我的系统上显示'ptr *'。您使用了哪些汇编标志?什么版本的g ++和gdb? – Thomas 2010-05-07 07:29:37
奇怪,我也使用gdb 7.1,但是g ++ 4.4.3。 4.5发布说明并不暗示在这个方向上有任何改变。 http://gcc.gnu.org/gcc-4.5/changes.html – Thomas 2010-05-07 07:59:44
只是为了填补更多的数据点,使用gdb 7.0.1我得到了正确的答案g ++ 4.2.4和4.3.3,但4.5。 0 gdb将指针显示为“void *”。看起来像gcc(或gdb?)中的错误 – 2010-05-07 08:57:05