** Description changed:

  I'm using Ubuntu 12.10 dev with gcc 4:4.7.0-5ubuntu1 and valgrind
  1:3.7.0-0ubuntu3. Here is the code example:
  
  #include <stdarg.h>
  #include <stdio.h>
  
  void test(char *var1, char *var2, char *var3, char *var4, char *var5, char 
*var6, int argc, ...)
  {
   va_list list;
  
   va_start(list, argc);
   if(va_arg(list, long int) == 1)
    printf("Test\n");
   va_end(list);
  }
  
  int main()
  {
   test(NULL, NULL, NULL, NULL, NULL, NULL, 1, 1);
   return 0;
  }
  
- 
- I have compiled it with "gcc -O3 -Wall -Wextra -o test -pedantic test.c" and 
tested with "valgrind ./test". The output is:
+ I have compiled it with "gcc -O3 -Wall -Wextra -o test -pedantic test.c"
+ and tested with "valgrind ./test". The output is:
  
  ==11060== Memcheck, a memory error detector
  ==11060== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
  ==11060== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
  ==11060== Command: ./test
  ==11060==
  ==11060== Conditional jump or move depends on uninitialised value(s)
  ==11060==    at 0x400575: test (in /home/sworddragon/data/test)
  ==11060==    by 0x400437: main (in /home/sworddragon/data/test)
  ==11060==
  Test
  ==11060==
  ==11060== HEAP SUMMARY:
  ==11060==     in use at exit: 0 bytes in 0 blocks
  ==11060==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
  ==11060==
  ==11060== All heap blocks were freed -- no leaks are possible
  ==11060==
  ==11060== For counts of detected and suppressed errors, rerun with: -v
  ==11060== Use --track-origins=yes to see where uninitialised values come from
  ==11060== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
  
- 
- Interestingly with 5 instead of 6 char * arguments before I'm getting the 
same error but without the output "Test". WIth less than 5 char * arguments 
before all is working fine.
+ Interestingly with 5 instead of 6 char * arguments before I'm getting
+ the same error but without the output "Test". With less than 5 char *
+ arguments before all is working fine.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/993193

Title:
  Error with Valgrind on variadic functions

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/993193/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to