Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / 20050527-1.c
blob1b32324471ffaef97e5aecfcb2db0cea409c0b32
1 /* PR c/21536 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -Wuninitialized" } */
5 typedef __SIZE_TYPE__ size_t;
6 extern void *malloc (size_t);
7 extern void free (void *);
9 void *
10 foo (int x, int y)
12 void *d = malloc (x * y * sizeof (double));
13 double (*e)[x][y] = d;
14 x += 10;
15 y += 10;
16 if (x > 18)
17 (*e)[x - 12][y - 12] = 0.0;
18 else
19 (*e)[x - 11][y - 11] = 1.0;
20 return d;
23 void *
24 bar (int x, int y)
26 void *d = malloc (x * y * sizeof (double));
27 struct S
29 double (*e)[x][y];
30 double (*f)[x][y];
31 } s;
32 s.e = d;
33 s.f = d;
34 x += 10;
35 y += 10;
36 if (x > 18)
37 (*s.e)[x - 12][y - 12] = 0.0;
38 else
39 (*s.e)[x - 11][y - 11] = 1.0;
40 if (x > 16)
41 (*s.f)[x - 13][y - 13] = 0.0;
42 else
43 (*s.f)[x - 14][y - 14] = 1.0;
44 return d;
47 int
48 main ()
50 void *d1 = foo (10, 10);
51 void *d2 = bar (10, 10);
52 free (d1);
53 free (d2);
54 return 0;