[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bison 1.28 gcc warnings cleanup patch
From: |
Peter Pentchev |
Subject: |
bison 1.28 gcc warnings cleanup patch |
Date: |
Fri, 8 Jun 2001 15:59:40 +0300 |
User-agent: |
Mutt/1.2.5i |
Hi,
When trying to compile a program generated with bison 1.28 using
the gcc -W option, the compiler complains about comparisons between
signed and unsigned. This causes problems when trying to produce
a 'clean' compile using -Wall -W -Werror ;)
The problem is in two comparisons of an int variable to a sizeof(),
on lines 614 and 626 of bison.simple. In an ideal world, the compiler
would be smart enough to realize that the start expression in the for
loop makes sure that x is *always* non-negative, and so a conversion
of the (non-negative) int x to the unsigned type needed for the comparison
against sizeof() would not cause any problems; however, GCC is not that
smart yet :)
So, here's a simple patch. The (size_t) cast could be changed to
something else, like (unsigned int) - I notice that (unsigned int)
is used in a couple of other places as a size type - but at least
on systems that define size_t, it should be the correct type.
G'luck,
Peter
--
If I were you, who would be reading this sentence?
--- src/bison.s1 Fri Jun 8 10:52:14 2001
+++ src/bison.s1 Fri Jun 8 10:52:29 2001
@@ -611,7 +611,7 @@
count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
+ (size_t) x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
msg = (char *) malloc(size + 15);
@@ -623,7 +623,7 @@
{
count = 0;
for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
+ (size_t) x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
strcat(msg, count == 0 ? ", expecting `" : " or `");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bison 1.28 gcc warnings cleanup patch,
Peter Pentchev <=