GCC Bugzilla – Bug 44985
warnings: gcc shifts integer by its entire size
Last modified: 2010-07-19 07:25:24 UTC
Hm, it seems on some 32bit systems, where there is no -m64, wideint can be a mere 32bits.
In which case the code should probably say:
hwi = ((hwi >> (shift - 1)) >> 1);
This was targeting OpenBSD/x86.
Maybe I should just stick need_64bit_hwint = yes on config.gcc for that and move along?
Assume there is always long long or __int64?
Coverage of this case is pretty rare now from my skimming.
> From: email@example.com
> To: firstname.lastname@example.org
> Subject: suggest assert wide_int larger than hashval_t
> Date: Mon, 19 Jul 2010 06:44:33 +0000
> I get this in 4.3.5:
> ../../gcc/gcc/varasm.c: In function `const_rtx_hash_1':
> ../../gcc/gcc/varasm.c:3387: warning: right shift count >= width of type
> ./include/hashtab.h:typedef unsigned int hashval_t;
> unsigned HOST_WIDE_INT hwi;
> hashval_t h, *hp;
> const int shift = sizeof (hashval_t) * CHAR_BIT;
> const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
> int i;
> h ^= (hashval_t) hwi;
> for (i = 1; i < n; ++i)
> hwi >>= shift; here
> It looks about the same in 4.5.0 except without const:
> int shift = (sizeof (hashval_t) * CHAR_BIT);
> Something is amiss here locally, for the types to be the same size.
> But maybe add gcc_assert(sizeof(hashval_t) < sizeof(HOST_WIDE_INT),
> outside the loop? It should be optimized away anyway.
> Maybe I'd get -Werror but I use -disable-bootstrap.
> Native compiler is gcc, but old.
> - Jay