This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Invalid right shift in genautomata.c
- From: Vladimir Makarov <vmakarov at redhat dot com>
- To: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 23 May 2002 15:19:39 -0400
- Subject: Re: Invalid right shift in genautomata.c
- References: <20020523180203.GA22190@daikokuya.demon.co.uk>
Neil Booth wrote:
>
> When compiling an i960-wrs-vxworks cross compiler I get
>
> gcc -c -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings
> -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic
> -Wno-long-long -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -I. -I../../gcc
> -I../../gcc/. -I../../gcc/config -I../../gcc/../include
> ../../gcc/genautomata.c -o genautomata.o
> ../../gcc/genautomata.c: In function `reserv_sets_hash_value':
> ../../gcc/genautomata.c:3419: warning: right shift count >= width of
> type
>
> IMO this is a bug and should be fixed.
>
Actually this is not a bug, Neil. The shift is not used when compiler
generates the message (it is even gone after dead code elimination).
To speed up genautomata, all bit operations are executed on
HOST_WIDE_INT. This type is used also to hash the bitstring. Htab uses
unsigned as a hash key. So I need to convert HOST_WIDE_INT into
unsigned. I could make it by `(unsigned) key'. But that would result
in bad hash keys when the number units > sizeof (unsigned) * CHAR_BIT.
Therefore I hash HOST_WIDE_INT using the shift. But it is made only
when sizeof (unsigned) < sizeof (HOST_WIDE_INT).
Vlad