Debian Codegraph @

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

raw
1 // PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.
2 // { dg-do compile { target c++20 } }
3
4 struct E {
5 constexpr E() = default;
6 constexpr E(int) {}
7 };
8
9 struct W {
10 [[no_unique_address]] E e;
11 int i;
12 constexpr W(int) : e(8), i(11) {}
13 };
14
15 constexpr W w = W(42);
16
17 struct S {
18 E e;
19 int i;
20 constexpr S() : e{}, i(11) { }
21 };
22
23 constexpr S s;
24
25 struct S2 {
26 [[no_unique_address]] E e;
27 int i;
28 constexpr S2() : e{}, i(11) { }
29 };
30
31 constexpr S2 s2;