Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-init6.C

raw
1 // PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.
2 // { dg-do compile { target c++20 } }
3
4 /* We used to get the "constexpr constructor for union S::<unnamed union>
5 must initialize exactly one non-static data member" error, but not anymore
6 in C++20. */
7
8 struct S {
9 union {
10 int i;
11 double d;
12 };
13 constexpr S() { }
14 };
15
16 union U {
17 int a;
18 constexpr U() { }
19 };
20
21 struct W {
22 union {
23 int a;
24 };
25 constexpr W() { }
26 };