Debian Codegraph @

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

raw
1 // PR c++/97388
2 // { dg-do compile { target c++20 } }
3
4 struct S {
5 int *s;
6 constexpr S () : s(new int) {} // { dg-error "is not a constant expression because allocated storage has not been deallocated" }
7 S (const S &) = delete;
8 S &operator= (const S &) = delete;
9 constexpr ~S () { delete s; }
10 };
11
12 constexpr bool
13 foo (S v)
14 {
15 v.s = nullptr;
16 return true;
17 }
18
19 static_assert (foo (S ())); // { dg-error "non-constant condition for static assertion" }