[PATCH 0/7] Fix invalid left shift of negative value.
DJ Delorie
dj@redhat.com
Fri Oct 30 17:14:00 GMT 2015
- 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.
More information about the Binutils
mailing list