tests/vg_regtest: Always evaluate prerequisite expressions with sh
[valgrind.git] / memcheck / tests / partial_load.c
blob0b2f10b6f4963323b5529fd66d2e4ef3127169e2
2 #include <stdlib.h>
3 #include <assert.h>
5 int main ( void )
7 long w;
8 int i;
9 char* p;
11 assert(sizeof(long) == sizeof(void*));
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, 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;