aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-lifetime1.C
blob: 36163844eca3eede9e836b1ebfea382cdf1fc2e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// { dg-do compile { target c++20 } }

#include "construct_at.h"

struct S { int x; };
constexpr int f() {
  S s;
  s.~S();
  std::construct_at(&s, 5);
  return s.x;
}
static_assert(f() == 5);

struct T { int x; constexpr ~T() {} };
constexpr int g() {
  T t;
  t.~T();
  std::construct_at(&t, 12);
  return t.x;
}
static_assert(g() == 12);