aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/constexpr-vla2.C
blob: 6cb1f708a238d23eca56f72ec8e6d49904f81942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// PR c++/69509
// { dg-do compile { target c++14 } }

constexpr int
fn_bad (int n)
{
  __extension__ int a [n] = { 0 };
  int z = a [0] + (n ? fn_bad (n - 1) : 0);
  return z;
}

constexpr int
fn_ok (int n)
{
  __extension__ int a [n] = { 0 };
  int z = a [0] + (n > 1 ? fn_ok (n - 1) : 0);
  return z;
}

constexpr int i1 = fn_ok (3);
constexpr int i2 = fn_bad (3); // { dg-error "array subscript out of bound" }