From 29c75ef27f5c06508d518ec3376f58aef6c65072 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 6 Sep 2019 07:37:26 +0200 Subject: [PATCH] glr.c: initialize vector of bools 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 5d4121b8..c9c6ce7d 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; }