aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/paren-init5.C
blob: 6d2efd70731ffdf782cea220e9fe0855ae996cb5 (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
// PR c++/91363 - P0960R3: Parenthesized initialization of aggregates.
// { dg-do run { target c++20 } }

union U {
  int a;
  float b;
};

// u1 has no active member
U u1;
// u2 zero-initializes the first member, so u2.a is the active member and
// its value is 0.
U u2 = U();
// u3 uses non-list aggregate initialization, so u3.a is the active member
// and its value is 1.
U u3 = U(1);

int
main ()
{
  if (u2.a != 0)
    __builtin_abort ();
  if (u3.a != 1)
    __builtin_abort ();
}