条件跳转或移动取决于指向第一行代码的未初始化值
我有一个程序在工作几天后崩溃,所以我决定使用 Valgrind 运行它。我已经清除了所有警告,但这个:
==30522== Conditional jump or move depends on uninitialised value(s)
==30522== at 0x405E32: main (main.c:548)
==30522== Uninitialised value was created by a stack allocation
==30522== at 0x405652: main (main.c:80)
main.c:80
是程序的第一行:
int main(int argc, char *argv[])
{ // <- this is the line 80
我想我已经清除了所有错误,但它仍然让我生气。这是怎么回事?
listado_ips->ocr=(float)listado_ips->ocr/tiempo_milisecs; // <-line 548
在此之前有几行:
milisecs1=milisecs1-milisecs2
tiempo_milisecs=(float)milisecs1/1000;
milisecs1
已初始化。
I have a program that crashes after some days of work, so I decided run it with Valgrind. I have cleaned up all the warnings but this one:
==30522== Conditional jump or move depends on uninitialised value(s)
==30522== at 0x405E32: main (main.c:548)
==30522== Uninitialised value was created by a stack allocation
==30522== at 0x405652: main (main.c:80)
main.c:80
is the first line of the program:
int main(int argc, char *argv[])
{ // <- this is the line 80
I think I already cleaned up all the bugs, but it still get me mad. What's up?
listado_ips->ocr=(float)listado_ips->ocr/tiempo_milisecs; // <-line 548
A couple lines before this:
milisecs1=milisecs1-milisecs2
tiempo_milisecs=(float)milisecs1/1000;
milisecs1
is initialised.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,在
main()
开始处创建的变量列表中,当您在第 548 行读取它时,至少有一个变量仍未初始化。因为您没有显示在第 548 行,以及第 80 行和第 548 行之间的内容,我们无法轻易告诉您更多信息。但请关注第 548 行,而不是第 80 行。
如果第 548 行是:
则分析 '
tiempo_milisecs
' 的设置位置。如果设置干净,那么您需要查看listado_ips->ocr
的设置位置。我们可以合理地安全地假设 listado_ips 本身(指针)已初始化。The problem is that in the list of variables created at the start of
main()
, there is at least one that is still uninitialized when you read it on line 548.Since you've not shown what's at line 548, nor what is between line 80 and 548, we can't easily tell you more. But concentrate on line 548 - not line 80.
If line 548 is:
then analyze where '
tiempo_milisecs
' is set. If that's set cleanly, then you need to look at wherelistado_ips->ocr
is set. We can reasonably safely assume thatlistado_ips
itself (the pointer) is initialized.