Re: Possible bug or simple nuisance compiler warning

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <[email protected]>
Hi Jot,

> Le 27 nov. 2020 à 02:15, Jot Dot <[email protected]> a écrit :
> 
> While beating my head senseless trying to get my first flex/bison (c++ style) project going,

Have you looked at the examples in examples/c++?

> 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). 

I have not received your message on help-bison (https://lists.gnu.org/r/help-bison/).

What do you mean by "I added a second error token into a rule"?  Could you please show that rule?


> 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. 

The definition of state_type depends on the grammar.  What is your definition?


> 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.

You may want to try another compiler too :)

> Due to the odd behaviour, I figure I'd run it past you just to make sure. 

Your compiler might be right.  I think it's unlikely, but it's possible.  To understand why it warns, I need the definition of state_type.

Cheers!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.