* RFA: Fix isl-ast-gen-if-1.c test
@ 2015-06-22 15:39 Nick Clifton
2015-06-22 15:41 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2015-06-22 15:39 UTC (permalink / raw)
To: gcc-patches
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;
}
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: Fix isl-ast-gen-if-1.c test
2015-06-22 15:39 RFA: Fix isl-ast-gen-if-1.c test Nick Clifton
@ 2015-06-22 15:41 ` Jeff Law
2015-06-22 16:08 ` Nicholas Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2015-06-22 15:41 UTC (permalink / raw)
To: Nick Clifton, gcc-patches
On 06/22/2015 09:38 AM, Nick Clifton wrote:
> 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.
I'd tend to prefer to change the size of the array -- adding another
conditional in the loop may have unintended consequences that possibly
scramble things just enough to compromise the test.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: Fix isl-ast-gen-if-1.c test
2015-06-22 15:41 ` Jeff Law
@ 2015-06-22 16:08 ` Nicholas Clifton
2015-06-22 16:20 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Clifton @ 2015-06-22 16:08 UTC (permalink / raw)
To: Jeff Law, gcc-patches
Hi Jeff,
> I'd tend to prefer to change the size of the array -- adding another
> conditional in the loop may have unintended consequences that possibly
> scramble things just enough to compromise the test.
Okey dokey, here is a revised version. Is this one OK ?
Cheers
Nick
gcc/ChangeLog
Index: 2015-06-22 Nick Clifton <nickc@redhat.com>
* gcc.dg/graphite/isl-ast-gen-if.c (main): Increase size of a
array to allow a[50] to be a valid location.
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)
@@ -28,7 +28,7 @@
int
main (void)
{
- int a[50];
+ int a[51]; /* NB This size allows foo's first iteration to write to
a[50]. */
foo (a, 50);
int res = array_sum (a);
if (res != 49)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: Fix isl-ast-gen-if-1.c test
2015-06-22 16:08 ` Nicholas Clifton
@ 2015-06-22 16:20 ` Jeff Law
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2015-06-22 16:20 UTC (permalink / raw)
To: Nicholas Clifton, gcc-patches
On 06/22/2015 10:07 AM, Nicholas Clifton wrote:
> Hi Jeff,
>
>> I'd tend to prefer to change the size of the array -- adding another
>> conditional in the loop may have unintended consequences that possibly
>> scramble things just enough to compromise the test.
>
> Okey dokey, here is a revised version. Is this one OK ?
>
> Cheers
> Nick
>
> gcc/ChangeLog
>
> Index: 2015-06-22 Nick Clifton <nickc@redhat.com>
>
> * gcc.dg/graphite/isl-ast-gen-if.c (main): Increase size of a
> array to allow a[50] to be a valid location.
OK.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-22 16:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22 15:39 RFA: Fix isl-ast-gen-if-1.c test Nick Clifton
2015-06-22 15:41 ` Jeff Law
2015-06-22 16:08 ` Nicholas Clifton
2015-06-22 16:20 ` Jeff Law
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).