下面是當我在Valgrind的運行我的代碼Valgrind的 - 錯誤
1)未初始化值由堆棧分配 ==在0x400EC1 16808 ==創建我得到的消息:的init()(Hite.cpp: 90)
2)大小的無效讀8
xmin=0.000000, xmax=1.000000, dx=0.010000, dt=0.000208, c=3.000000
==2763== Conditional jump or move depends on uninitialised value(s)
==2763== at 0x3E5420E836: __ieee754_exp (in /lib64/libm-2.12.so)
==2763== by 0x3E54224A81: exp (in /lib64/libm-2.12.so)
==2763== by 0x400F88: init() (Hite.cpp:96)
==2763== by 0x4010C8: main (Hite.cpp:114)
==2763== Uninitialised value was created by a stack allocation
==2763== at 0x400EC1: init() (Hite.cpp:90)
==2763==
==2763== Use of uninitialised value of size 8
==2763== at 0x3E5420E8EC: __ieee754_exp (in /lib64/libm-2.12.so)
==2763== by 0x3E54224A81: exp (in /lib64/libm-2.12.so)
==2763== by 0x400F88: init() (Hite.cpp:96)
==2763== by 0x4010C8: main (Hite.cpp:114)
==2763== Uninitialised value was created by a stack allocation
==2763== at 0x400EC1: init() (Hite.cpp:90)
我們如何從上而產生
90 void init() {
91 double xmin=0;
92 double xavg = 0.5*(xmin+xmax);
int main(int argc,char **argv) {
112 printf("xmin=%f, xmax=%f, dx=%f, dt=%f, c=%f\n",
113 xmin=0,xmax=0,dx=0,dt=0,c=0);
114 init()
來這些錯誤
;
你可以在Hite.cpp周圍顯示行:90? – Grzegorz
請更多代碼,沒有足夠的信息來說明問題所在。 – john
您是否從函數返回值? –