[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible bug or simple nuisance compiler warning
From: |
Jot Dot |
Subject: |
Possible bug or simple nuisance compiler warning |
Date: |
Thu, 26 Nov 2020 18:15:42 -0700 (MST) |
While beating my head senseless trying to get my first flex/bison (c++ style)
project going, I've come across this issue:
I try to catch some error tokens inside my bison rules to aid me by supplying
diagnostic output.
I added a second error token into a rule to debug an issue I'm trying to figure
out (which I posted in help-bison).
win_flex 2.6.4
bison (GNU Bison) 3.7.1
Now my Microsoft compiler returns with:
1>D:\data\c\FlexBisonLoader\My_Parser\parser.cpp(454,26): warning C4244:
'return': conversion from 'const short' to 'gen::Parser::state_type', possible
loss of data
The following snippet of code in the generated .cpp source file:
Parser ::state_type
Parser ::yy_lr_goto_state_ (state_type yystate, int yysym)
{
int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
return yytable_[yyr];
else
return yydefgoto_[yysym - YYNTOKENS]; <<<<<<<< Warning.
}
Now this is probably just a nuisance message that can be safely ignored, but I
wanted to bring it up to your attention.
IMO the return value just needs to be cast to Parser::state_type.
Strange thing is I still have another error token left in the grammar . When I
go from one to two error tokens, it gives me this warning. Remove the second
one and the warning goes away. It does not matter which rule I place the second
error token in.
I would have thought the warning would exist every time I put it in, not after
'n' occurrences.
Also, when I add that extra error line, my app freezes. Now, I'm 99% sure this
freeze is from what I'm doing, but that 1% tells me that I've never had this
compile issue, It's a bit odd, and this parser is a state engine which might be
in the wrong place.. etc. I've already triggered two Microsoft bugs in this
single project / endeavour, slowing me down, so now I'm getting a bit paranoid.
Due to the odd behaviour, I figure I'd run it past you just to make sure.
Sorry to be a bother. Thanks for reading this.
- Possible bug or simple nuisance compiler warning,
Jot Dot <=