drd: Add a consistency check
[valgrind.git] / memcheck / tests / varinfo2.c
blob97079c255d427f6c0b5b9d998606ea7f6724e7f9
2 /* Check for correct handling of nested scopes in a zero-biased
3 executable. */
5 /* Relevant compile flags are:
7 -Wall -g -I$prefix/include/valgrind
9 eg -Wall -g -I`pwd`/Inst/include/valgrind
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <assert.h>
15 #include "memcheck/memcheck.h"
17 /* Cause memcheck to complain about the address "a" and so to print
18 its best guess as to what "a" actually is. a must be
19 addressible. */
21 void croak ( void* aV )
23 char* a = (char*)aV;
24 char* undefp = malloc(1);
25 char saved = *a;
26 assert(undefp);
27 *a = *undefp;
28 (void) VALGRIND_CHECK_MEM_IS_DEFINED(a, 1);
29 *a = saved;
30 free(undefp);
33 #include <stdio.h>
35 void foo ( void )
37 int var;
38 var = 1;
39 { char var[10];
40 var[6] = 4;
41 croak( &var[7] );
42 { struct { double foo; float bar; } var;
43 croak ( 2 + (char*)&var.bar );
46 croak( 1 + (char*)&var );
49 int main ( void )
51 foo();
52 return 0;