array bound violation in reg-stack.c
Herman ten Brugge
Haj.Ten.Brugge@net.HCC.nl
Fri Jul 16 11:20:00 GMT 1999
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_stack):
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 index.
--- 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. */
- do
+ if (new->top != -1) do
{
/* Swap the reg at top of stack into the position it is
supposed to be in, until the correct top of stack appears. */
More information about the Gcc-patches
mailing list