Avoid some left-shifts of negative constants
Paul Eggert
eggert@cs.ucla.edu
Thu Feb 7 18:01:00 GMT 2019
On 2/7/19 9:14 AM, Joseph Myers wrote:
> If the code is doing left shifts of
> negative values, that may well indicate an unsigned type would have made
> the intended semantics clearer, even if a signed type does work in that
> code.
Although that might be true elsewhere, there is a reasonable argument
that the code is clearer as-is for this particular case, as it's more
robust in the presence of integer-width changes. I'd like to see cases
where the code is obviously clearer after being rewritten to use
unsigned shifts, before conceding that it's worthwhile to spend time to
pacify -Wshift-negative-value.
More information about the Libc-alpha
mailing list