Debian Codegraph @

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

raw
1 // P0784R7
2 // { dg-do compile { target c++20 } }
3 // { dg-additional-options "-fdelete-null-pointer-checks" }
4
5 template <int N>
6 constexpr bool
7 foo (const char (&x)[N])
8 {
9 int **p = new int *[N];
10 for (int i = 0; i < N; i++)
11 p[i] = new int (x[i]);
12 for (int i = 0; i < N; i++)
13 if (*p[i] != x[i])
14 return false;
15 for (int i = 0; i < N; ++i)
16 delete p[i];
17 delete[] p;
18 return true;
19 }
20
21 constexpr bool a = foo ("foobar");
22 static_assert (a);