[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bison 1.30e porting problem on 64-bit hosts with deeply nested inputs
From: |
Paul Eggert |
Subject: |
Bison 1.30e porting problem on 64-bit hosts with deeply nested inputs |
Date: |
Wed, 28 Nov 2001 17:40:48 -0800 (PST) |
Here is a patch to some portability problems with parsers generated by
Bison 1.30e. The problem occurs on 64-bit hosts when you are parsing
very deeply nested input files (e.g., 2**31 '('s followed by 2**31 ')'s).
This patch also adds a comment about the current implementation's
limits on YYMAXDEPTH.
2001-11-28 Paul Eggert <address@hidden>
* src/bison.simple (yyparse): Do not limit the number of items
in the stack to a value that fits in 'int', as this is an
arbitrary limit on hosts with 64-bit size_t and 32-bit int.
===================================================================
RCS file: src/bison.simple,v
retrieving revision 1.30.5.3
retrieving revision 1.30.5.4
diff -pu -r1.30.5.3 -r1.30.5.4
--- src/bison.simple 2001/11/28 20:22:52 1.30.5.3
+++ src/bison.simple 2001/11/29 01:36:07 1.30.5.4
@@ -216,7 +216,12 @@ int yydebug;
#endif
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used). */
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
#if YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif
@@ -360,7 +365,7 @@ yyparse (YYPARSE_PARAM_ARG)
# define YYPOPSTACK (yyvsp--, yyssp--)
#endif
- int yystacksize = YYINITDEPTH;
+ size_t yystacksize = YYINITDEPTH;
/* The variables used to return semantic value and location from the
@@ -408,7 +413,7 @@ yyparse (YYPARSE_PARAM_ARG)
if (yyssp >= yyss + yystacksize - 1)
{
/* Get the current used size of the three stacks, in elements. */
- int size = yyssp - yyss + 1;
+ size_t size = yyssp - yyss + 1;
#ifdef yyoverflow
{
@@ -469,7 +474,8 @@ yyparse (YYPARSE_PARAM_ARG)
yylsp = yyls + size - 1;
#endif
- YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
if (yyssp >= yyss + yystacksize - 1)
YYABORT;
@@ -686,7 +692,7 @@ yyerrlab:
if (yyn > YYFLAG && yyn < YYLAST)
{
- int size = 0;
+ size_t size = 0;
char *msg;
int x, count;
- Bison 1.30e porting problem on 64-bit hosts with deeply nested inputs,
Paul Eggert <=