[PATCH] gas: microblaze: fix shift overflow

Michael Eager eager@eagerm.com
Mon Nov 16 16:22:00 GMT 2015


On 11/14/2015 11:49 PM, Mike Frysinger wrote:
> This code tries to shift an integer 31 bits which triggers a werror:
> gas/config/tc-microblaze.c:742:21: error: integer overflow in expression [-Werror=overflow]
>    e->X_add_number |= -(1 << 31);
>
> Cast the 1 to offsetT to match X_add_number to fix things.
>
> 2015-11-15  Mike Frysinger  <vapier@gentoo.org>
>
> 	* config/tc-microblaze.c (parse_imm): Add an offsetT cast.
> ---
>   gas/config/tc-microblaze.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
> index ac7c828..0ec24f8 100644
> --- a/gas/config/tc-microblaze.c
> +++ b/gas/config/tc-microblaze.c
> @@ -739,7 +739,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
>       {
>         /* Special case: sign extend negative 32-bit values to 64-bits.  */
>         if ((e->X_add_number >> 31) == 1)
> -	e->X_add_number |= -(1 << 31);
> +	e->X_add_number |= -((offsetT) 1 << 31);
>
>         if (e->X_add_number < min || e->X_add_number > max)
>   	{

OK.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



More information about the Binutils mailing list