Byacc 1.9 - array out of bound in byacc (not generated) code. (D.Borkov)
27 Jan 1999 12:13:48 -0500

          From comp.compilers

Related articles
Byacc 1.9 - array out of bound in byacc (not generated) code. (1999-01-27)
| List of all articles for this month |

From: (D.Borkov)
Newsgroups: comp.compilers
Date: 27 Jan 1999 12:13:48 -0500
Organization: Nyx Net, Free Internet access (
Keywords: yacc, errors

I believe there is a bug in byacc v1.9 code - not generated code.
In the function pack_vector() in the file output.c
approximately around the line 569.

Here is the old and the new code illustrating the problem.

+++ if (loc >= maxtable)
+++ {
+++ if (loc >= MAXTABLE)

CORRECT (I believe) CODE:
--- if (loc >= maxtable - 1)
--- {
--- if (loc >= MAXTABLE - 1)

The problem is that in the old code the "check[]"
array could be completely filled in the statement

        check[loc] = from[k];

when the index "loc" reaches "(maxtable-1)".

Then there would be no space left for at least one "(-1)" at the end
of the "check[]" array and the index "lowzero" could end up pointing
outside proper bounds in the following loop near the end of the same

        while (check[lowzero] != -1)

I would appreciate someone checking this fix, and, if correct, adding
it to a publicly available archive since I have no means of doing
so. Mailing me the article would be nice too, since I would hate to
miss the consequent postings :-).

Drazen <>

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.