Home | History | Annotate | Download | only in tests
      1 
      2 #include <stdlib.h>
      3 #include <assert.h>
      4 
      5 int main ( void )
      6 {
      7   long  w;
      8   int   i;
      9   char* p;
     10 
     11   assert(sizeof(long) == sizeof(void*));
     12 
     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);
     18 
     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);
     26 
     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);
     32 
     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;
     38 
     39   /* dump result in a way gcc can't understand */
     40   for (i = 0; i < 64; i++)
     41      w <<= 1;
     42 
     43   return (int)w;
     44 }
     45 
     46