我一直在学习C The Hard Way直到练习6,我经常遇到这个错误而不知道如何解决它。
我对C很新,并且我不确定这意味着什么,这个valgrind错误的大多数问题是由于引用了未初始化的值,但在这种情况下,是否已经在调用之前已经显式初始化了距离?
我在Mac,OS X 10.10.2(14C109)上。
Valgrind-3.11.0.SVN通过brew安装,brew安装--HEAD valgrind。
这是我的C代码:
#include <stdio.h>
int main()
{
int distance = 100;
printf("You are %d miles away.\n", distance);
return 0;
}
这是我的valgrind日志的相关部分:
==14578== Conditional jump or move depends on uninitialised value(s)
==14578== at 0x1003FBC3F: _platform_memchr$VARIANT$Haswell (in /usr/lib/system/libsystem_platform.dylib)
==14578== by 0x1001EFB96: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==14578== by 0x1001F9FE5: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==14578== by 0x10021F9AE: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==14578== by 0x10021FC80: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==14578== by 0x1001F5B71: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==14578== by 0x1001F39D7: printf (in /usr/lib/system/libsystem_c.dylib)
==14578== by 0x100000F46: main (ex6.c:6)
==14578== Uninitialised value was created by a stack allocation
==14578== at 0x1001F5BF8: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==14578==
You are 100 miles away.