]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR tree-optimization/87072 - false warning: array subscript is above array bounds
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Aug 2018 19:39:18 +0000 (19:39 +0000)
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Aug 2018 19:39:18 +0000 (19:39 +0000)
gcc/testsuite/ChangeLog:
* gcc.dg/Warray-bounds-35.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263822 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Warray-bounds-35.c [new file with mode: 0644]

index bf2295bcdea89318304369d73083ca4c0a2985ac..e83279f7f9b0ead0f880bf0ef5503db0751c42dd 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-23  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/87072
+       * gcc.dg/Warray-bounds-35.c: New test.
+
 2018-08-23  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/87024
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-35.c b/gcc/testsuite/gcc.dg/Warray-bounds-35.c
new file mode 100644 (file)
index 0000000..b3ad362
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR tree-optimization/87072 - g++6.2.0 false warning: array subscript
+   is above array bounds, with misleading line number
+   { dg-do compile }
+   { dg-options "-O3 -Wall" }  */
+
+int a[10];
+
+void f (unsigned n)
+{
+  for (unsigned j = 0; j < n; j++) {
+     for (unsigned k = 0; k < j; k++)
+       a[j] += k;                       /* { dg-bogus "\\\[-Warray-bounds]" } */
+     a[j] += j;
+  }
+}