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: Sat, 30 Nov 2019 06:52:50 +0100

Hi,

I did some more tests and got some new compiler warnings:

% cat test.yy
%skeleton "lalr1.cc"
%code { int yylex (int *); }
%%
a:
  "t1"
| "t2"
| "t3"
| "t4"
| "t5"
| "t6"
| "t7"
| "t8"
| "t9"
| "t10"
| "t11"
| "t12"
| "t13"
| "t14"
| "t15"
| "t16"
| "t17"
| "t18"
| "t19"
| "t20"
| "t21"
| "t22"
| "t23"
| "t24"
| "t25"
| "t26"
| "t27"
| "t28"
| "t29"
| "t30"
| "t31"
| "t32"
| "t33"
| "t34"
| "t35"
| "t36"
| "t37"
| "t38"
| "t39"
| "t40"
| "t41"
| "t42"
| "t43"
| "t44"
| "t45"
| "t46"
| "t47"
| "t48"
| "t49"
| "t50"
| "t51"
| "t52"
| "t53"
| "t54"
| "t55"
| "t56"
| "t57"
| "t58"
| "t59"
| "t60"
| "t61"
| "t62"
| "t63"
| "t64"
| "t65"
| "t66"
| "t67"
| "t68"
| "t69"
| "t70"
| "t71"
| "t72"
| "t73"
| "t74"
| "t75"
| "t76"
| "t77"
| "t78"
| "t79"
| "t80"
| "t81"
| "t82"
| "t83"
| "t84"
| "t85"
| "t86"
| "t87"
| "t88"
| "t89"
| "t90"
| "t91"
| "t92"
| "t93"
| "t94"
| "t95"
| "t96"
| "t97"
| "t98"
| "t99"
| "t100"
| "t101"
| "t102"
| "t103"
| "t104"
| "t105"
| "t106"
| "t107"
| "t108"
| "t109"
| "t110"
| "t111"
| "t112"
| "t113"
| "t114"
| "t115"
| "t116"
| "t117"
| "t118"
| "t119"
| "t120"
| "t121"
| "t122"
| "t123"
| "t124"
| "t125"
| "t126"
;
% bison -o test.cc test.yy
% g++-7 -Wextra -Wuseless-cast -c test.cc
test.cc: In member function 'yy::parser::symbol_number_type 
yy::parser::by_state::type_get() const':
test.cc:872:15: warning: comparison is always false due to limited range of 
data type [-Wtype-limits]
     if (state == empty_state)
         ~~~~~~^~~~~~~~~~~~~~
test.cc: In static member function 'static yy::parser::token_number_type 
yy::parser::yytranslate_(int)':
test.cc:1620:28: warning: useless cast to type 'int' [-Wuseless-cast]
     if (static_cast<int> (t) <= yyeof_)
                            ^
test.cc:1622:33: warning: useless cast to type 'int' [-Wuseless-cast]
     else if (static_cast<int> (t) <= user_token_number_max_)
                                 ^

The latter warnings could perhaps be silenced by replacing
"static_cast<int> (t)" with "int { t }", but I don't know enough
about the context to tell if that's correct and safe.

The first warning vanishes with g++-9, but it might be a real issue.
Though C[++] type promotion rules are still a horror to me, the
following test program seems to do what Bison does and yields "0"
(either compiler version, either compiled as C or C++) which
(assuming that's correct for C[++]) would indicate that Bison's
comparison is wrong.

#include <stdio.h>

int main ()
{
  enum { empty_state = -1 };
  unsigned char c = empty_state;
  printf ("%i\n", c == empty_state);
}

Regards,
Frank



reply via email to

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