RE: [PATCH 00/11] treewide: Fix a bunch of shift overflows

From: David Laight
Date: Wed Apr 06 2022 - 09:01:29 EST


From: Borislav Petkov
> Sent: 05 April 2022 16:15
...
> Due to some recent changes which added -fsanitize-shift to the build
> options of an allmodconfig, it started failing here with an old gcc
> because getting an overflow while shifting is undefined C99 behavior.

Annoyingly it is extremely unlikely that a 2s compliment
system would ever generate anything other than the expected
value - ie the value obtained by doing the calculation
with unsigned values and then getting the result cast back
to signed (which is IIRC implementation defined).

It isn't as though there are many 1s compliment systems out
there, and probably even fewer 'sign overpunch' ones.
Never mind trying to find a working C compiler for them.

What sort of crack are the C standards body and compiler
people actually smoking?

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)