3

The challenge is to clear all Valgrind errors before going on to the next lesson, but I don't really know what's wrong with this program. I want to know what's wrong before going on. Thanks, appreciate the help.

#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;
}

Here's the valgrind report:

==41714== Memcheck, a memory error detector
==41714== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==41714== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==41714== Command: ./ex3
==41714== 
==41714== Conditional jump or move depends on uninitialised value(s)
==41714==    at 0x1003FBC3F: _platform_memchr$VARIANT$Haswell (in /usr/lib/system/libsystem_platform.dylib)
==41714==    by 0x1001EFBB6: __sfvwrite (in /usr/lib/system/libsystem_c.dylib)
==41714==    by 0x1001FA005: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==41714==    by 0x10021F9CE: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==41714==    by 0x10021FCA0: __xvprintf (in /usr/lib/system/libsystem_c.dylib)
==41714==    by 0x1001F5B91: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==41714==    by 0x1001F39F7: printf (in /usr/lib/system/libsystem_c.dylib)
==41714==    by 0x100000F4D: main (ex3.c:8)
==41714== 
I am 10 years old.
I am 72 inches tall.
==41714== 
==41714== HEAP SUMMARY:
==41714==     in use at exit: 38,816 bytes in 426 blocks
==41714==   total heap usage: 507 allocs, 81 frees, 44,960 bytes allocated
==41714== 
==41714== LEAK SUMMARY:
==41714==    definitely lost: 0 bytes in 0 blocks
==41714==    indirectly lost: 0 bytes in 0 blocks
==41714==      possibly lost: 0 bytes in 0 blocks
==41714==    still reachable: 4,096 bytes in 1 blocks
==41714==         suppressed: 34,720 bytes in 425 blocks
==41714== Rerun with --leak-check=full to see details of leaked memory
==41714== 
==41714== For counts of detected and suppressed errors, rerun with: -v
==41714== Use --track-origins=yes to see where uninitialised values come from
==41714== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
user3758745
  • 777
  • 1
  • 6
  • 19

1 Answers1

1

There are very clearly no memory issues. You never even malloc or free anything, so at this point all memory is handled without you being involved. This must be an issue with the Valgrind. If you are using OSX perhaps try on a machine with linux if you have one available.

AndrewGrant
  • 786
  • 7
  • 17