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

struct S {
  int *s;
  constexpr S () : s(new int) {}	// { dg-error "is not a constant expression because allocated storage has not been deallocated" }
  S (const S &) = delete;
  S &operator= (const S &) = delete;
  constexpr ~S () { delete s; }
};

constexpr bool
foo (S v)
{
  v.s = nullptr;
  return true;
}

static_assert (foo (S ()));	// { dg-error "non-constant condition for static assertion" }