2018-04-09 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / 20041219-1.c
blob4fdc9540d51ac36d355600038040e8da7eac3b03
1 /* PR18191 Struct member is not getting default-initialized.
2 Origin: Grigory Zagorodnev <grigory.zagorodnev@intel.com> */
4 /* { dg-do run } */
6 extern int printf (__const char *__restrict __format, ...);
8 typedef struct S {
9 const char* s;
10 int i;
11 } S;
13 void
14 foo (void)
16 S dummy[2];
17 unsigned i;
19 /* Put some garbage on the stack. */
20 for (i = 0; i < sizeof(dummy); i++)
21 ((char *)&dummy)[i] = -1;
24 int
25 bar (void)
27 /* Allocate object on the stack. */
28 S obj[2] = { {"m0"}, {"m1"} };
30 /* Assume fields those not explicitly initialized
31 are default initialized to 0 [8.5.1/7 and 8.5/5]. */
32 if (obj[0].i == 0)
33 return 0;
34 else
36 printf("Failed: obj[0].i == '%d', expecting '0'\n", obj[0].i);
37 return 1;
41 int
42 main (void)
44 foo();
45 return bar();