[PATCH] Fix undefined behaviour in arc port

Andreas Schwab schwab@linux-m68k.org
Sat Sep 26 13:30:00 GMT 2015


Jeff Law <law@redhat.com> writes:

> @@ -9320,7 +9320,9 @@ arc_legitimize_reload_address (rtx *p, machine_mode mode, int opnum,
>        if ((scale-1) & offset)
>  	scale = 1;
>        shift = scale >> 1;
> -      offset_base = (offset + (256 << shift)) & (-512 << shift);
> +      offset_base
> +	= ((offset + (256 << shift))
> +	   & ((HOST_WIDE_INT)(-512U << shift)));

If HOST_WIDE_INT is bigger than int then this is not the same.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gcc-patches mailing list