From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id D4DA73959C89; Tue, 6 Dec 2022 07:24:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4DA73959C89 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670311452; bh=C9WYrFsm3XaAE6y7FLTelKe8Hug3EPRgwjcTusVwBRI=; h=From:To:Subject:Date:From; b=mYYPNNTwYj2BJZsbM0Gf5CitEAdXuomp8aSTjw6bZ33LQSBv/5UxDoH3ekxY8HUGa SLPxOqA6QmgbbI7ZfS6I5mzmzK0VW9Jb1259rH4Gj/hpmjmAZOGurMkrQbGQayiQGS LZfkz6IZguuLtZKKRu4mp7otKZo8WCZkHem9E+tk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4499] tree-optimization/104165 - bougs -Warray-bounds, add testcase X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 6a6f2cbf9ab366ea38cbe4c8d574486ce2bbe873 X-Git-Newrev: 790ff87f675f28bce5e7e35918ae09c3ece4ec4d Message-Id: <20221206072412.D4DA73959C89@sourceware.org> Date: Tue, 6 Dec 2022 07:24:12 +0000 (GMT) List-Id: https://gcc.gnu.org/g:790ff87f675f28bce5e7e35918ae09c3ece4ec4d commit r13-4499-g790ff87f675f28bce5e7e35918ae09c3ece4ec4d Author: Richard Biener 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 + +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); +}