当前位置 : 主页 > 手机开发 > 无线 >

valgrind错误:条件跳转或移动取决于未初始化的值

来源:互联网 收集:自由互联 发布时间:2021-06-10
看我有一个程序 #include stdio.hint call(){ int x=25; ++x; return x; } int main(){ int ptr; ptr=call(); printf("%d",ptr); return 0;} 当我使用-g选项编译它时用valgrind运行它显示 ==15469== 1 errors in context 1 of 8:==154
看我有一个程序

#include <stdio.h>

int  call(){ 
int x=25; 
++x; 
return x; 
} 

int main(){ 
int ptr; 
ptr=call(); 
printf("%d",ptr); 
return 0;
}

当我使用-g选项&编译它时用valgrind运行它显示

==15469== 1 errors in context 1 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546F83: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E6CC: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 1 errors in context 2 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546E01: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E6CC: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 1 errors in context 3 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546DF9: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E6CC: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 1 errors in context 4 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546E01: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 1 errors in context 5 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546DF9: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 2 errors in context 6 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546F83: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 2 errors in context 7 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x547871: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== 
==15469== 4 errors in context 8 of 8:
==15469== Conditional jump or move depends on uninitialised value(s)
==15469==    at 0x546F4D: _dl_relocate_object (in /lib/ld-2.12.90.so)
==15469==    by 0x53E7D9: dl_main (in /lib/ld-2.12.90.so)
==15469==    by 0x55094D: _dl_sysdep_start (in /lib/ld-2.12.90.so)
==15469==    by 0x540222: _dl_start (in /lib/ld-2.12.90.so)
==15469==    by 0x53B876: ??? (in /lib/ld-2.12.90.so)
==15469== 
==15469== ERROR SUMMARY: 13 errors from 8 contexts (suppressed: 0 from 0)

我不知道为什么我收到这个错误?

这是什么意思 ?

我怎么能删除它?

他们怎么会伤害我的节目?

这些不是来自您的代码,而是来自/lib/ld-*.so,它是动态库加载器.

这是一个广泛使用的代码片段,我很难想象它有如此明显的错误,所以我认为valgrind会给你误报.你可以安全地忽略它们.

网友评论