This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: Fix isl-ast-gen-if-1.c test
- From: Nick Clifton <nickc at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Jun 2015 16:38:29 +0100
- Subject: RFA: Fix isl-ast-gen-if-1.c test
- Authentication-results: sourceware.org; auth=none
Hi Guys,
The test file gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c file
was generating an unexpected failure for the RX. When I investigated
I found that a return address on the stack was being corrupted, and I
tracked it down to the foo() function:
foo (int a[], int n)
{
int i;
for (i = 0; i < n; i++)
{
if (i < 25)
a[i] = i;
a[n - i] = 1;
}
}
The problem is that when i is 0, the line a[n - i] writes to a[50]
which is beyond the end of the a array. (In the RX case it writes
over the return address on the stack).
The patch below fixes the problem, although it could also be solved by
increasing the size of the a array when it is declared in main().
OK to apply ?
Cheers
Nick
gcc/testsuite/ChangeLog
2015-06-22 Nick Clifton <nickc@redhat.com>
* gcc.dg/graphite/isl-ast-gen-if-1.c (foo): Prevent writing after
the end of the array.
Index: gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c
===================================================================
--- gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c (revision 224722)
+++ gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c (working copy)
@@ -10,7 +10,8 @@
{
if (i < 25)
a[i] = i;
- a[n - i] = 1;
+ if (i > 0)
+ a[n - i] = 1;
}
}