* [PATCH] tree-optimization/104165 - bougs -Warray-bounds, add testcase
@ 2022-12-06 7:23 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-12-06 7:23 UTC (permalink / raw)
To: gcc-patches
The following adds the testcase from the description which was
fixed by r13-2894-gbe4a6551ed37c1.
Tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/104165
* g++.dg/warn/Warray-bounds-pr104165-1.C: New testcase.
---
.../g++.dg/warn/Warray-bounds-pr104165-1.C | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/warn/Warray-bounds-pr104165-1.C
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 00000000000..bc46285eb90
--- /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);
+}
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-06 7:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06 7:23 [PATCH] tree-optimization/104165 - bougs -Warray-bounds, add testcase Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).