| 1 |
// PR c++/91363 - P0960R3: Parenthesized initialization of aggregates. |
| 2 |
// { dg-do run { target c++20 } } |
| 3 |
|
| 4 |
union U { |
| 5 |
int a; |
| 6 |
float b; |
| 7 |
}; |
| 8 |
|
| 9 |
// u1 has no active member |
| 10 |
U u1; |
| 11 |
// u2 zero-initializes the first member, so u2.a is the active member and |
| 12 |
// its value is 0. |
| 13 |
U u2 = U(); |
| 14 |
// u3 uses non-list aggregate initialization, so u3.a is the active member |
| 15 |
// and its value is 1. |
| 16 |
U u3 = U(1); |
| 17 |
|
| 18 |
int |
| 19 |
main () |
| 20 |
{ |
| 21 |
if (u2.a != 0) |
| 22 |
__builtin_abort (); |
| 23 |
if (u3.a != 1) |
| 24 |
__builtin_abort (); |
| 25 |
} |