aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-init14.C
blob: 1335e51c853b2767975277096cf90a3e34f0893a (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
// PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.
// { dg-do compile { target c++20 } }

struct E {
  constexpr E() = default;
  constexpr E(int) {}
};

struct W {
  [[no_unique_address]] E e;
  constexpr W(int) : e(8) {}
};

constexpr W w = W(42);

struct S {
  E e;
  constexpr S() : e{} { }
};

constexpr S s;

struct S2 {
  [[no_unique_address]] E e;
  constexpr S2() : e{} { }
};

constexpr S2 s2;