Debian Codegraph @

gcc/testsuite/g++.dg/warn/Warray-bounds-5.C

raw
1 // { dg-do compile }
2 // { dg-options "-O2 -Warray-bounds" }
3
4 void f();
5
6 int c[3];
7 int result;
8
9 struct Vector {
10 static int get(int i) {
11 if (i >= 3)
12 f();
13 return c[i];
14 }
15 };
16
17 void g()
18 {
19 for (int i = 0; i < 3; ++i) {
20 const int index = i % 3;
21 result = Vector::get(index) + Vector::get(index);
22 }
23 }
24