aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-new24.C
blob: ee62f18922c58e53472488856683def5fe4cd415 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// PR c++/118775
// { dg-do compile { target c++20 } }

int a;

constexpr char *
f1 ()
{
  constexpr auto p = new char[(long int) &a]; // { dg-error "size not constant" }
  return p;
}

constexpr char *
f2 ()
{
  auto p = new char[(long int) &a];  // { dg-error "size not constant" }
  return p;
}

void
g ()
{
  auto r1 = f2 ();
  constexpr auto r2 = f2 (); // { dg-message "in .constexpr. expansion" }
}