This is the mail archive of the
mailing list for the glibc project.
Re: Avoid some left-shifts of negative constants
On Thu, 7 Feb 2019, Paul Eggert wrote:
> 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
Such changes (if a future processor supports 2^31 or more hardware threads
sharing the same cache) would require the constant to change anyway,
because they only make sense if you might be shifting by 32 or more, so -1
would also be invalid. They'd also require various other changes in the
code, given that the existing CPUID interfaces used by this code use
fields too narrow to return such large values.
Joseph S. Myers