ppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.
[valgrind.git] / memcheck / tests / varinfo4.c
blob71643cdea92f548a2fe07e23507a53a244016922
2 /* A small demo of providing descriptions of structured types in error
3 messages. */
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>
34 #include <string.h>
36 typedef struct { short c1; char* c2[3]; } XX;
38 typedef
39 struct _str { int bing; int bong; XX xyzzy[77]; }
40 Str;
42 __attribute__((noinline))
43 int blah ( int x, int y )
45 Str a[10];
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;
54 int main ( void )
56 printf("answer is %d\n", blah(3,7) );
57 return 0;