[PATCH] S/390: Fix invalid left shift of negative integer value.

Dimitry Andric dimitry@andric.com
Fri Oct 30 16:43:00 GMT 2015


On 30 Oct 2015, at 15:27, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> 
> On Fri, Oct 30, 2015 at 01:45:11PM +0100, Andreas Schwab wrote:
>> Dominik Vogt <vogt@linux.vnet.ibm.com> writes:
>>> -  return ((addr + (1 << align) - 1) & (-1 << align));
>>> +  return ((addr + (1 << align) - 1) & (~0u << align));
>> 
>> This is not the same if valueT is wider than int.
> 
> You're right.  I'll fix that and send a new patch in a different
> thread with fixes for all such shifts in binutils_gdb.

In FreeBSD, I fixed most of the warnings of this type by replacing
(-1 << x) with -(1 << x).  That is most often what was intended.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://sourceware.org/pipermail/binutils/attachments/20151030/5f6a6791/attachment.sig>


More information about the Binutils mailing list