"Joel E. Denny" <[EMAIL PROTECTED]> writes: > It occurs to me now that I really cast the wrong thing. In > yycheck[i]==other_value, I shouldn't have cast yycheck[i] to int. I > should have cast other_value to unsigned int.
The story is a bit complicated, but here it is. Originally yacc was designed to use only int types. Bison follows in this tradition, which means that on most modern hosts Bison-generated parsers silently mishandle grammars whose state numbers etc. don't fit in the 2 Gi range. Such grammars don't come up in practice (as far as I am aware anyway) so this is not a practical problem, and nobody has taken time to fix the (theoretical) bugs. Fixing them properly would take quite a bit of painstaking work. One thing yacc did historically, though, and Bison follows in this tradition, is to store tables of small 'int' values in arrays of narrower types like 'unsigned char' or 'short'. This is done only to save space; the values are intended to be 'int' values. Hence it is correct to convert the yycheck value to 'int'; the only reason *yycheck is not 'int' is to save space. > I fear we may lose legitimate warnings. We may, but that's life. There are too many false alarms with that particular warning. I have some practical experience in this area. And I take some responsibility for it, as I put some of those warnings into GCC in the first place. In retrospect we should not have made them the default for -W, but it's too late to change this now.
