Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / uninit-pr89230-2.c
blob473d2da5d3d2fbf30c43b1a5dcadb4fef9f18fe2
1 /* PR middle-end/89230 - Bogus uninited usage warning with printf
2 { dg-do compile }
3 { dg-options "-O2 -Wall" } */
5 typedef __SIZE_TYPE__ size_t;
7 extern void* memset (void*, int, size_t);
8 extern int printf (const char*, ...);
9 extern int rand (void);
11 struct S
13 int a;
14 int b;
17 struct H
19 int c;
20 int d;
23 void getblk (void* blk)
25 struct S* s = (struct S*) blk;
26 memset (blk, 0, 512);
27 s->a = rand () & 1;
30 struct H* gethdr (void* blk)
32 memset (blk, 0, 512);
33 return rand () & 1 ? (struct H*) blk : 0;
36 int main (void)
38 char blk[512], tmp[512];
39 struct S *s = (struct S*) blk;
40 struct H *h;
42 getblk (blk);
44 if (s->a || !(h = gethdr (tmp)) || s->a != h->d) {
46 printf ("%d\n", s->b);
47 if (s->a)
48 printf ("s->a = %d\n", s->a);
49 else if (!h)
50 printf ("!h\n");
51 else
52 printf ("h->d = %d\n", h->d);