aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-dtor5.C
blob: 1739afbcc680d9444038ef45a26c8e6ff5f14837 (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
29
30
31
32
33
34
35
// PR c++/97388
// { dg-do compile { target c++20 } }

struct S {
  int m;
  constexpr S () : m(1) {}
  constexpr ~S () noexcept (false) { if (m == 1) { throw; } }
};

constexpr bool
foo (S v)
{
  v.m = 2;
  return true;
}

constexpr bool
bar ()
{
  return foo (S ());
}

constexpr bool
baz ()
{
  foo (S ());
  return foo (S ());
}

static_assert (foo (S ()));
static_assert (bar ());
static_assert (baz ());
constexpr bool x = foo (S ());
constexpr bool y = bar ();
constexpr bool z = baz ();