gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-require-effective-target c++11 } |
| 3 | // { dg-options "-O2 -Warray-bounds" } |
| 4 | |
| 5 | #include <algorithm> |
| 6 | |
| 7 | static int bar(int n, int l) |
| 8 | { |
| 9 | int f[l]; |
| 10 | int x = 0; |
| 11 | int r = n; |
| 12 | |
| 13 | for (; x < l;) |
| 14 | if (r) |
| 15 | x = l; |
| 16 | else |
| 17 | r = 1; |
| 18 | |
| 19 | if (r == 1) |
| 20 | std::sort(f, f + x, [](int a, int b) { return a > b; }); |
| 21 | return 1; |
| 22 | } |
| 23 | |
| 24 | int foo(int n) |
| 25 | { |
| 26 | return bar(n, 4); |
| 27 | } |