bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Frank Heckenbach
Subject: Re: [Bison-Announce] Bison 3.4.91 released [beta]
Date: Sun, 01 Dec 2019 09:15:54 +0100

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]