mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-02 08:40:26 +08:00
tree-optimization/104165 - bougs -Warray-bounds, add testcase
The following adds the testcase from the description which was fixed by r13-2894-gbe4a6551ed37c1. PR tree-optimization/104165 * g++.dg/warn/Warray-bounds-pr104165-1.C: New testcase.
This commit is contained in:
parent
6a6f2cbf9a
commit
790ff87f67
27
gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C
Normal file
27
gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C
Normal file
@ -0,0 +1,27 @@
|
||||
// { dg-do compile }
|
||||
// { dg-require-effective-target c++11 }
|
||||
// { dg-options "-O2 -Warray-bounds" }
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
static int bar(int n, int l)
|
||||
{
|
||||
int f[l];
|
||||
int x = 0;
|
||||
int r = n;
|
||||
|
||||
for (; x < l;)
|
||||
if (r)
|
||||
x = l;
|
||||
else
|
||||
r = 1;
|
||||
|
||||
if (r == 1)
|
||||
std::sort(f, f + x, [](int a, int b) { return a > b; });
|
||||
return 1;
|
||||
}
|
||||
|
||||
int foo(int n)
|
||||
{
|
||||
return bar(n, 4);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user