comparison gcc/testsuite/gcc.dg/20041219-1.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* PR18191 Struct member is not getting default-initialized.
2 Origin: Grigory Zagorodnev <grigory.zagorodnev@intel.com> */
3
4 /* { dg-do run } */
5
6 extern int printf (__const char *__restrict __format, ...);
7
8 typedef struct S {
9 const char* s;
10 int i;
11 } S;
12
13 void
14 foo (void)
15 {
16 S dummy[2];
17 unsigned i;
18
19 /* Put some garbage on the stack. */
20 for (i = 0; i < sizeof(dummy); i++)
21 ((char *)&dummy)[i] = -1;
22 }
23
24 int
25 bar (void)
26 {
27 /* Allocate object on the stack. */
28 S obj[2] = { {"m0"}, {"m1"} };
29
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
35 {
36 printf("Failed: obj[0].i == '%d', expecting '0'\n", obj[0].i);
37 return 1;
38 }
39 }
40
41 int
42 main (void)
43 {
44 foo();
45 return bar();
46 }
47