Hi all
Try to find the errors in this C/C++ snippet using valgrind:
#include <stdio.h>
/* Save as code.c */
int main(void)
{
int i=-1,a[2],b[2],c[2];
a[0] = 1; a[1] = 2;
b[0] = 3; b[1] = 4;
c[0] = 5; c[1] = 6;
printf("%i %in",b[i],a[i]);
return 0;
}
Compile using "gcc -o bla code.c -Wall" and check the code using
"valgrind ./bla".
Valgrind finds nothing even though I index a[-1] and b[-1] - not
good...
Insure++ would for sure find the negative index, but GCC nor Valgrind
will get it...
Are there supplementary tools I should check? Or can I in some way
supplement my compile process so that valgrind could alert me?
Obviously I could augment the code so the the bad negative value of "i"
could be found from runtime specific parameters, i.e. static code
checking is not relevant for me.
Best
/pto
--
Peter Toft, PhD
http://petertoft.dk
------------------------------------------------------------------------------
RSA® Conference 2012
Save $700 by Nov 18
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users