extern void abort(void); #include void reach_error() { assert(0); } #include int *a, *b; int n; #define BLOCK_SIZE 128 void foo () { int i; for (i = 0; i < n; i++) a[i] = -1; for (i = 0; i < BLOCK_SIZE - 1; i++) b[i] = -1; } int main () { n = BLOCK_SIZE; a = malloc (n * sizeof(*a)); b = malloc (n * sizeof(*b)); *b++ = 0; foo (); if (b[-2]) /* invalid deref */ { free(a); free(b-1); } else { free(a); free(b-1); } return 0; }