aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init/array39.C
blob: 2fd89377162807b4c83de1fd3c6ecfb6b207ae19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// PR c++/65154
// { dg-do run { target c++11 } }

int cnt1 = 0,
    cnt2 = 0;

struct S_empty
{
    S_empty () {
	cnt1++;
    };
};

struct C1
{
  S_empty s;
};

struct S_init
{
  S_init () : i(42)
  {
    cnt2++;
  };
  int i;
};

struct C2
{
  S_init a, b;
};

int
main ()
{
  C1 c1[5]{};
  C2 c2[1]{};

  if (c2[0].a.i != 42 || c2[0].b.i != 42)
    return 1;

  if (cnt1 != 5 || cnt2 != 2)
    return 1;

  return 0;
}