Debian Codegraph @

gcc/testsuite/g++.dg/init/array39.C

raw
1 // PR c++/65154
2 // { dg-do run { target c++11 } }
3
4 int cnt1 = 0,
5 cnt2 = 0;
6
7 struct S_empty
8 {
9 S_empty () {
10 cnt1++;
11 };
12 };
13
14 struct C1
15 {
16 S_empty s;
17 };
18
19 struct S_init
20 {
21 S_init () : i(42)
22 {
23 cnt2++;
24 };
25 int i;
26 };
27
28 struct C2
29 {
30 S_init a, b;
31 };
32
33 int
34 main ()
35 {
36 C1 c1[5]{};
37 C2 c2[1]{};
38
39 if (c2[0].a.i != 42 || c2[0].b.i != 42)
40 return 1;
41
42 if (cnt1 != 5 || cnt2 != 2)
43 return 1;
44
45 return 0;
46 }