view gcc/testsuite/g++.dg/cpp2a/constexpr-new2.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

// P0784R7
// { dg-do compile { target c++2a } }
// { dg-additional-options "-fdelete-null-pointer-checks" }

template <int N>
constexpr bool
foo (const char (&x)[N])
{
  int **p = new int *[N];
  for (int i = 0; i < N; i++)
    p[i] = new int (x[i]);
  for (int i = 0; i < N; i++)
    if (*p[i] != x[i])
      return false;
  for (int i = 0; i < N; ++i)
    delete p[i];
  delete[] p;
  return true;
}

constexpr bool a = foo ("foobar");
static_assert (a);