Debian Codegraph @

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

raw
1 // { dg-do compile { target c++20 } }
2
3 #include "construct_at.h"
4
5 struct S { int x; };
6 constexpr int f() {
7 S s;
8 s.~S();
9 std::construct_at(&s, 5);
10 return s.x;
11 }
12 static_assert(f() == 5);
13
14 struct T { int x; constexpr ~T() {} };
15 constexpr int g() {
16 T t;
17 t.~T();
18 std::construct_at(&t, 12);
19 return t.x;
20 }
21 static_assert(g() == 12);