aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/constexpr-vla1.C
blob: 21eb93dc65429c34ed1f74adc48980062d362a75 (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
26
27
28
29
30
// PR c++/69496
// { dg-do compile { target c++14 } }

constexpr int
fn_ok (int n)
{
    __extension__ int a[n] = { };
    int z = 0;

    for (unsigned i = 0; i < sizeof (a) / sizeof (int); ++i)
      z += a[i];

    return z;
}


constexpr int
fn_not_ok (int n)
{
    __extension__ int a[n] = { };
    int z = 0;

    for (unsigned i = 0; i < sizeof (a); ++i)
      z += a[i];

    return z;
}

constexpr int n1 = fn_ok (3);
constexpr int n2 = fn_not_ok (3); // { dg-error "array subscript" }