gcc/testsuite/g++.dg/warn/Warray-bounds-6.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-options "-O3 -Warray-bounds" } |
| 3 | |
| 4 | struct type { |
| 5 | bool a, b; |
| 6 | bool get_b() { return b; } |
| 7 | }; |
| 8 | |
| 9 | type stuff[9u]; |
| 10 | |
| 11 | void bar(); |
| 12 | |
| 13 | void foo() |
| 14 | { |
| 15 | for(unsigned i = 0u; i < 9u; i++) |
| 16 | { |
| 17 | if(!stuff[i].a) |
| 18 | continue; |
| 19 | |
| 20 | bar(); |
| 21 | |
| 22 | for(unsigned j = i + 1u; j < 9u; j++) |
| 23 | if(stuff[j].a && stuff[j].get_b()) // { dg-bogus "above array bounds" } |
| 24 | return; |
| 25 | } |
| 26 | } |