aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C27
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);
+}