> Le 18 août 2018 à 19:44, Paul Eggert <[email protected]> a écrit : > > Akim Demaille wrote: >> You did that for the compilers that do not support the pragma. ISTR that I >> was in favor of always initializing yylval, but you commented that that >> would prevent the compiler from reporting the user that she forgot to set >> yylval :) >> Unfortunately it seems that it does not work: if we take the input.y file >> from my previous message and_remove_ the definition of yylval in yoles >> then… GCC no longer warns! > > That's very strange. Can you send me the C file that GCC is not complaining > about, but should complain? Along with the gcc options you're using?
There you are!
--- yylval-is-set.y 2018-08-19 09:32:34.985921138 +0200
+++ yylval-is-not-set.y 2018-08-19 09:33:04.246656396 +0200
@@ -4,7 +4,7 @@
static int yylex (YYSTYPE *lvalp)
{
static char const *input = "aa";
- *lvalp = 1;
+ //*lvalp = 1;
return *input++;
}
$ ~/src/gnu/bison/_build/8s/tests/bison yylval-is-set.y -o yylval-is-set.c
$ ~/src/gnu/bison/_build/8s/tests/bison yylval-is-not-set.y -o
yylval-is-not-set.c
$ g++-mp-8 -O2 -Wmaybe-uninitialized yylval-is-set.c
yylval-is-set.c: In function 'int yyparse()':
yylval-is-set.c:976:9: warning: 'yylval' may be used uninitialized in this
function [-Wmaybe-uninitialized]
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
^~~~~~
$ g++-mp-8 -O2 -Wmaybe-uninitialized yylval-is-not-set.c
$
$ g++-mp-8 --version
g++-mp-8 (MacPorts gcc8 8.2.0_0) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
yylval-is-not-set.c
Description: Binary data
yylval-is-not-set.y
Description: Binary data
yylval-is-set.c
Description: Binary data
yylval-is-set.y
Description: Binary data
