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

struct S {
  int *s;
  constexpr S () : s(new int) {}
  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" }
// { dg-error "is not a constant expression because allocated storage has not been deallocated" "" { target *-*-* } .-1 }