diff options
author | Richard Biener <rguenther@suse.de> | 2022-12-06 08:22:01 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-12-06 08:23:56 +0100 |
commit | 790ff87f675f28bce5e7e35918ae09c3ece4ec4d (patch) | |
tree | fc6ab96bf68052091381e6cc34c0dc436f00b7dd | |
parent | 6a6f2cbf9ab366ea38cbe4c8d574486ce2bbe873 (diff) | |
download | gcc-790ff87f675f28bce5e7e35918ae09c3ece4ec4d.zip gcc-790ff87f675f28bce5e7e35918ae09c3ece4ec4d.tar.gz gcc-790ff87f675f28bce5e7e35918ae09c3ece4ec4d.tar.bz2 |
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.
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C new file mode 100644 index 0000000..bc46285 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C @@ -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); +} |