[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] glr.c: initialize vector of bools
From: |
Akim Demaille |
Subject: |
[PATCH 6/6] glr.c: initialize vector of bools |
Date: |
Fri, 6 Sep 2019 22:27:53 +0200 |
The CI, with CC='gcc-7 -fsanitize=undefined,address
-fno-omit-frame-pointer', reports:
calc.cc:1652:50: runtime error: load of value 190, which is not a valid
value for type 'bool'
../../tests/calc.at:867: cat stderr
--- expout 2019-09-05 20:30:37.887257545 +0000
+++
/home/travis/build/bison-3.4.1.72-79a1-dirty/_build/tests/testsuite.dir/at-groups/438/stdout
2019-09-05 20:30:37.887257545 +0000
@@ -1 +1,2 @@
syntax error
+calc.cc:1652:50: runtime error: load of value 190, which is not a valid
value for type 'bool'
438. calc.at:867: 438. Calculator glr.cc (calc.at:867): FAILED
(calc.at:867)
The problem is that yylookaheadNeeds is not initialized in
yyinitStateSet, and when it is copied, the value is not 0 or 1.
* data/skeletons/glr.c (yylookaheadNeeds): Initialize yylookaheadNeeds.
---
data/skeletons/glr.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 55cf3830..7ef1a047 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -1094,17 +1094,20 @@ yyinitStateSet (yyGLRStateSet* yyset)
{
yyset->yysize = 1;
yyset->yycapacity = 16;
- yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
+ yyset->yystates
+ = (yyGLRState**) YYMALLOC (yyset->yycapacity * sizeof yyset->yystates[0]);
if (! yyset->yystates)
return yyfalse;
yyset->yystates[0] = YY_NULLPTR;
- yyset->yylookaheadNeeds =
- (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
+ yyset->yylookaheadNeeds
+ = (yybool*) YYMALLOC (yyset->yycapacity * sizeof
yyset->yylookaheadNeeds[0]);
if (! yyset->yylookaheadNeeds)
{
YYFREE (yyset->yystates);
return yyfalse;
}
+ memset (yyset->yylookaheadNeeds,
+ 0, yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
return yytrue;
}
--
2.23.0
- [PATCH 0/6] More CI and fixes, Akim Demaille, 2019/09/06
- [PATCH 1/6] CI: fail fast, Akim Demaille, 2019/09/06
- [PATCH 3/6] style: fix comment, Akim Demaille, 2019/09/06
- [PATCH 2/6] CI: more compilers, Akim Demaille, 2019/09/06
- [PATCH 4/6] lalr1.cc: fix LAC support, Akim Demaille, 2019/09/06
- [PATCH 5/6] yacc.c: beware of GCC's -Wmaybe-uninitialized, Akim Demaille, 2019/09/06
- [PATCH 6/6] glr.c: initialize vector of bools,
Akim Demaille <=