Valgrind未初始化的值错误

时间:2015-11-19 23:12:31

标签: c macos valgrind

我试图Learn C The Hard Way,我刚刚介绍了Valgrind。我从一些破解的代码开始并修复它,现在我有以下C代码,对我来说看起来是正确的:

#include <stdio.h>

int main() {
    int age = 10;
    int height = 72;

    printf("I am %d years old.\n", age);
    printf("I am %d inches tall.\n", height);

    return 0;
}

但是当我使用cc -Wall -g ex4.c -o ex4编译并运行Valgrind时,我得到以下内容:

==6903== Memcheck, a memory error detector
==6903== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==6903== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==6903== Command: ./ex4
==6903==
==6903== Conditional jump or move depends on uninitialised value(s)
==6903==    at 0x1003DDC3F: _platform_memchr$VARIANT$Haswell (in /usr/lib/system/libsystem_platform.dylib)
==6903==    by 0x1001D19F6: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==6903==    by 0x1001DBE45: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==6903==    by 0x10020180E: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==6903==    by 0x100201AE0: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==6903==    by 0x1001D79D1: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==6903==    by 0x1001D5837: printf (in /usr/lib/system/libsystem_c.dylib)
==6903==    by 0x100000F2D: main (ex4.c:8)
==6903==
I am 10 years old.
I am 72 inches tall.
==6903==
==6903== HEAP SUMMARY:
==6903==     in use at exit: 38,487 bytes in 414 blocks
==6903==   total heap usage: 514 allocs, 100 frees, 45,463 bytes allocated
==6903==
==6903== LEAK SUMMARY:
==6903==    definitely lost: 0 bytes in 0 blocks
==6903==    indirectly lost: 0 bytes in 0 blocks
==6903==      possibly lost: 0 bytes in 0 blocks
==6903==    still reachable: 4,096 bytes in 1 blocks
==6903==         suppressed: 34,391 bytes in 413 blocks
==6903== Rerun with --leak-check=full to see details of leaked memory
==6903==
==6903== For counts of detected and suppressed errors, rerun with: -v
==6903== Use --track-origins=yes to see where uninitialised values come from
==6903== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)

这里出了什么问题?我使用的是OS X 10.10,cc --version给出了

Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

0 个答案:

没有答案