public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-4499] tree-optimization/104165 - bougs -Warray-bounds, add testcase
Date: Tue,  6 Dec 2022 07:24:12 +0000 (GMT)	[thread overview]
Message-ID: <20221206072412.D4DA73959C89@sourceware.org> (raw)

https://gcc.gnu.org/g:790ff87f675f28bce5e7e35918ae09c3ece4ec4d

commit r13-4499-g790ff87f675f28bce5e7e35918ae09c3ece4ec4d
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Dec 6 08:22:01 2022 +0100

    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.

Diff:
---
 .../g++.dg/warn/Warray-bounds-pr104165-1.C         | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

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);
+}

                 reply	other threads:[~2022-12-06  7:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221206072412.D4DA73959C89@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).