regtest: remove compiler warnings with clang
[valgrind.git] / memcheck / tests / partial_load.c
blob685ca8d23e8a5d0577d34220d644abc171f95930
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <assert.h>
5 int main ( void )
7 long w; int i; char* p;
8 assert(sizeof(long) == sizeof(void*));
9 #if defined(__powerpc64__)
10 fprintf (stderr, "powerpc64\n"); /* Used to select correct .exp file. */
11 #endif
13 /* partial load, which --partial-loads-ok=yes should suppress */
14 p = calloc( sizeof(long)-1, 1 );
15 assert(p);
16 w = *(long*)p;
17 free(p);
19 /* partial but misaligned, ppc64[le] ok, but otherwise cannot be suppressed */
20 p = calloc( sizeof(long), 1 );
21 assert(p);
22 p++;
23 w += *(long*)p;
24 p--;
25 free(p);
27 /* partial but not word sized, cannot be suppressed */
28 p = calloc( sizeof(short)-1, 1 );
29 assert(p);
30 w += (long)( *(short*)p );
31 free(p);
33 /* aligned, word sized, but completely invalid - cannot be suppressed */
34 p = calloc( sizeof(long), 1 );
35 assert(p);
36 free(p);
37 w += *(long*)p;
39 /* dump result in a way gcc can't understand */
40 for (i = 0; i < 64; i++)
41 w <<= 1;
43 return (int)w;