[PATCH 0/7] Fix invalid left shift of negative value.
Andreas Schwab
schwab@linux-m68k.org
Fri Oct 30 17:26:00 GMT 2015
DJ Delorie <dj@redhat.com> writes:
> - return ((size + (1 << align) - 1) & (-1 << align));
> + return ((size + (1 << align) - 1) & -(1 << align));
>
> This is an annoying new rule to remember. Would this be a valid substitution?
>
> return ((size + (1 << align) - 1) & (~0 << align));
>
> In cases where we're forming bitmasks, a mathematical negation doesn't
> "fit" as well as logical operations.
~0 is still a negative number.
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 Binutils
mailing list