./:
[official-gcc.git] / gcc / testsuite / gcc.c-torture / compile / 20020706-1.c
blobc8811bc68ff8772c0d1bf80b5d7064c848774a7e
1 // Contributed by Alexandre Oliva <aoliva@redhat.com>
2 // From Red Hat case 106165.
4 typedef struct s1
6 unsigned short v1;
7 unsigned char *v2;
8 } S1;
10 extern void bar(const struct s1 *const hdb);
11 extern unsigned char* foo ();
13 unsigned int sn;
14 S1 *hdb;
15 S1 *pb;
16 unsigned short len;
18 unsigned int crashIt()
20 unsigned char *p;
21 unsigned int nsn;
22 unsigned short cnt;
24 if (sn != 0) return 1;
26 if ((len < 12) || ((p = (((pb->v1) >= 8) ? pb->v2 : foo() )) == 0))
27 return 1;
29 nsn = (
30 (((*(unsigned int*)p) & 0x000000ff) << 24) |
31 (((*(unsigned int*)p) & 0x0000ff00) << 8) |
32 (((*(unsigned int*)p) & 0x00ff0000) >> 8) |
33 (((*(unsigned int*)p) & 0xff000000) >> 24) );
34 p += 4;
36 cnt = (unsigned short) ((
37 (((*(unsigned int*)p) & 0x000000ff) << 24) |
38 (((*(unsigned int*)p) & 0x0000ff00) << 8) |
39 (((*(unsigned int*)p) & 0x00ff0000) >> 8) |
40 (((*(unsigned int*)p) & 0xff000000) >> 24) ) &
41 0xffff);
43 if ((len != 12 + (cnt * 56)) || (nsn == 0))
45 bar(hdb);
46 return 1;
49 return 0;