Re: [Bison-Announce] Bison 3.4.91 released [beta]

Frank Heckenbach <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <E1ibKOY-0003Jf-Ij@goedel>
Akim Demaille wrote:

> > % g++-7 -Wextra -Wuseless-cast -c test.cc
> 
> Doh...  Yet another compiler flag...

Yes, I like to enable as many warnings in my code as I reasonably
can. :)

> This one is really troublesome, I don't think I'll eliminate all the warnings before 3.5.

No sweat about the warnings, but if the empty_state comparison is
actually wrong (if my test was correct), this might be more urgent.
AFAICS, it would then access yystos_[0xff], out of bounds (usually).

> --- a/data/skeletons/c++.m4
> +++ b/data/skeletons/c++.m4
> @@ -545,7 +545,7 @@ m4_define([b4_yytranslate_define],
>      const int user_token_number_max_ = ]b4_user_token_number_max[;
>      const token_number_type undef_token_ = ]b4_undef_token_number[;
>  
> -    if (static_cast<int> (t) <= yyeof_)
> +    if (t <= 0)
>        return yyeof_;
>      else if (static_cast<int> (t) <= user_token_number_max_)
>        return translate_table[t];

You did notice there's another "static_cast<int> (t)" in the
"else if" line?

If you can't use "int { t }" as I suggested (doesn't work with older
C++ standards, does it?), maybe you can use a temporary like
"int tt = t;" to avoid both casts at once.

Regards,
Frank
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.