This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: array bound violation in reg-stack.c
- To: Herman ten Brugge <Haj dot Ten dot Brugge at net dot HCC dot nl>
- Subject: Re: array bound violation in reg-stack.c
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 02 Aug 1999 00:49:36 -0600
- cc: egcs-patches at egcs dot cygnus dot com
- Reply-To: law at cygnus dot com
In message <199907161921.UAA02927@net.HCC.nl>you write:
> Hello,
>
> I am currently working on using bounds-checking on gcc itself. I found
> a problem in reg-stack.c. The problem is with the statement (in change_stac
> k):
>
> while (old->reg[old->top] != new->reg[new->top])
>
> The value of 'old->top' and 'new->top' can be -1. This will result
> in some random data being used for the compare. This problem is present
> since gcc-2.7.2.1.
> The patch to fix this is simple:
>
> 1999-07-13 Herman A.J. ten Brugge <Haj.Ten.Brugge@net.HCC.nl>
>
> * reg-stack.c (change_stack) Fixed problem with negative array inde
> x.
>
> --- reg-stack.c.org Tue Jul 13 18:21:58 1999
> +++ reg-stack.c Tue Jul 13 18:47:18 1999
> @@ -2647,7 +2647,7 @@ change_stack (insn, old, new, when)
> other regs. But since we never swap any other reg away from
> its correct slot, this algorithm will converge. */
I will not install this patch without a better explanation of the problem.
You need to describe how you get to this condition and explain why it is
valid to have a value of -1 for new->top at this point in the code.
It would also be a significant benefit if you could provide a testcase.
jeff