2 /* A small demo of providing descriptions of structured types in error
5 /* Relevant compile flags are:
7 -Wall -g -I$prefix/include/valgrind
9 eg -Wall -g -I`pwd`/Inst/include/valgrind
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
21 void croak ( void* aV
)
24 char* undefp
= malloc(1);
28 (void) VALGRIND_CHECK_MEM_IS_DEFINED(a
, 1);
36 typedef struct { short c1
; char* c2
[3]; } XX
;
39 struct _str
{ int bing
; int bong
; XX xyzzy
[77]; }
42 __attribute__((noinline
))
43 int blah ( int x
, int y
)
46 memset(a
, 0, sizeof(a
));
47 croak(1 + (char*)(&a
[3].xyzzy
[x
*y
].c1
));
48 croak( (char*)(&a
[5].bong
) );
49 croak( 1 + (char*)(&a
[3].xyzzy
[x
*y
].c2
[2]) );
50 memset(a
, 0, sizeof(a
));
51 return a
[3].xyzzy
[x
*y
].c1
;
56 printf("answer is %d\n", blah(3,7) );