1 ONLY(!) if you want to check bound overflows with EMX/GCC 2.7.2.1 you
2 have to change some lines within yaccsrc.c. (or the skeleton file bison.simple
3 if you really know what you are doing).
4 If you are using checker (together with gcc -fcheck-memory-usage) look at
7 Reason: The skeleton file will produce a bounds checking error. This is NOT
8 a real error. The code uses initially a pointer to the first element BEFORE
9 an array; the pointer will be incremented before the first use. This is a
10 problem for the bounds checker. It detects an illegal pointer al the
11 initialization and sets the value of the pointer to invalid (-1) the first
12 assignment crashes the program.
14 You will see here the patches in the function yyparse. First, look at the
15 code near the beginning of the function and apply the following changes:
21 > yychar = YYEMPTY; /* Cause a token to be read. */
23 > /* Initialize stack pointers.
24 > Waste one element of value and location stack
25 > so that they stay on the same level as the state stack.
26 > The wasted elements are never initialized. */
34 >/* Push a new state, which is found in yystate . */
35 >/* In all cases, when you get here, the value and location stacks
36 > have just been pushed. so pushing a state here evens the stacks. */
41 > if (yyssp >= yyss + yystacksize - 1)
47 > yychar = YYEMPTY; /* Cause a token to be read. */
49 > /* Initialize stack pointers.
50 > Waste one element of value and location stack
51 > so that they stay on the same level as the state stack.
52 > The wasted elements are never initialized. */
54 > yyssp = yyss; /* FGC: allow -fbounds-checking */
62 >/* Push a new state, which is found in yystate . */
63 >/* In all cases, when you get here, the value and location stacks
64 > have just been pushed. so pushing a state here evens the stacks. */
68 >yyfirststart: /* FGC */
69 > *yyssp = (short) yystate; /* FGC */
71 > if (yyssp >= yyss + yystacksize - 1)
73 Now, look at the end of yyparse.
79 > short *ssp1 = yyss - 1;
80 > fprintf (stderr, "state stack now");
81 > while (ssp1 != yyssp)
82 > fprintf (stderr, " %d", *++ssp1);
83 > fprintf (stderr, "\n");
91 > short *ssp1 = yyss; /* FGC */
92 > fprintf (stderr, "state stack now");
93 > while (ssp1 != yyssp)
94 > fprintf (stderr, " %d", *++ssp1);
95 > fprintf (stderr, "\n");
99 NEVER use this code in a delevopement environment. There may be some
100 problems with it, I never checked the changes in all conditions. Let's wait
101 for the bison gurus to fix these problems by themselves.
103 ------------ THE FOLLOW CHANGES SHOULD BE APPLIED FOR CHECKER ONLY -------------
104 Look at the beginning of yyparse and replace
105 > YYSTYPE yyval; /* the variable used to return */
107 > YYSTYPE yyval = 0; /* the variable used to return */
109 Furthermore, initialize yyvsa[0], e.g. add the line
115 That's OK in all circumstances and may be applied without any risk.