Julian Seward 31b741dc9b Merge the Ptrcheck tool from branches/PTRCHECK r8619.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8620
2008-09-18 14:43:05 +00:00

19 lines
524 B
C

#include <stdlib.h>
int main(void)
{
// When I had n-u --> u, this gave a false positive... can happen because
// p+up can give n if you are (un)lucky, because the result is close enough
// to zero.
int u[20];
int* p = malloc(sizeof(int) * 100);
p[0] = 0; // ok
int* n = (int*)((long)p + (long)u); // result is n, because near zero!
int* x = (int*)((long)n - (long)u); // x == p
x[0] = 0; // ok, originally caused false pos.
return 0;
}