[Bug 993193] Re: Error with Valgrind on variadic functions
bnuytten
993193 at bugs.launchpad.net
Sun Jul 22 20:18:42 UTC 2012
va_list list = {{0}}; /*
quick&dirty, avoids valgrind messages:
- Conditional jump or move depends on uninitialised value(s)
- Use of uninitialised value of size 8
compiler warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
*/
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/993193
Title:
Error with Valgrind on variadic functions
Status in “gcc-defaults” package in Ubuntu:
Confirmed
Bug description:
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:
==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.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/993193/+subscriptions
More information about the foundations-bugs
mailing list