C语言 Valgrind“条件跳转或移动取决于未初始化的值”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4113918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Valgrind "Conditional jump or move depends on uninitialised value(s)" Error
提问by Tim Sarbin
I am getting many errors with valgrind saying "Conditional jump or move depends on uninitialized value(s)".
我在 valgrind 中遇到很多错误,说“条件跳转或移动取决于未初始化的值”。
Below is the one of the blocks. All of them are similar:
下面是块之一。它们都是相似的:
vasm_sourceline_info_t* line = asmState->firstLine;
if (line == NULL) return;
while ((line = line->next) != NULL)
{
printf ("[%s(%i)] %s\n", line->fileName, line->lineNumber, line->data);
}
The error itself is on the while() line. vasm_sourceline_infois a doubly linked list structure. The code ~works~ but this error is worrying. Is there something else in code stomping on memory, or is the above function flawed in some way?
错误本身在 while() 行上。vasm_sourceline_info是一个双向链表结构。代码~有效~但这个错误令人担忧。代码中是否还有其他东西在内存上踩踏,或者上述功能是否存在某种缺陷?
回答by Matt Joiner
回答by sepp2k
There's nothing wrong with the code per se, but if one of the lines' nextfield has not been initialized (presumably the last line's nextfield), that would explain the message.
代码本身没有任何问题,但如果其中一行的next字段尚未初始化(大概是最后一行的next字段),则可以解释该消息。

