gcc/testsuite/g++.dg/cpp2a/constexpr-new9.C
raw| 1 | // PR c++/91369 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | // { dg-additional-options "-fdelete-null-pointer-checks" } |
| 4 | |
| 5 | struct S { |
| 6 | constexpr S (int *i) : i{i} {} |
| 7 | constexpr ~S () { delete[] i; } |
| 8 | int *i; |
| 9 | }; |
| 10 | |
| 11 | constexpr S foo (int x) { return { new int[x] () }; } |
| 12 | constexpr bool bar () { foo (1); return true; } |
| 13 | constexpr bool baz () { foo (1); return false; } |
| 14 | |
| 15 | static_assert (bar ()); |
| 16 | static_assert (!baz ()); |