aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/warn/Warray-bounds-5.C
blob: 06d776a400bb78f92eb16f0fc13b9b1fa99a1ef0 (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
// { dg-do compile }
// { dg-options "-O2 -Warray-bounds" }

void f();

int c[3];
int result;

struct Vector {
    static int get(int i) {
        if (i >= 3)
            f();
        return c[i];
    }
};

void g()
{
    for (int i = 0; i < 3; ++i) {
        const int index = i % 3;
        result = Vector::get(index) + Vector::get(index);
    }
}