gcc/testsuite/g++.dg/cpp2a/constexpr-dtor8.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) {} |
| 7 | S (const S &) = delete; |
| 8 | S &operator= (const S &) = delete; |
| 9 | constexpr ~S () { delete s; } // { dg-error "already deallocated" } |
| 10 | }; |
| 11 | |
| 12 | constexpr bool |
| 13 | foo (S v) |
| 14 | { |
| 15 | delete v.s; |
| 16 | return true; |
| 17 | } |
| 18 | |
| 19 | static_assert (foo (S ())); // { dg-error "non-constant condition for static assertion" } |