[chbot] Pop quiz C
Mike Field
hamster at snap.net.nz
Wed Apr 26 06:20:23 BST 2017
On 26/04/2017 4:31 PM, Mike Field wrote:
> It doesn't matter if the target is 8, 16, 32 or 64 bits - it will be
> none-zero, and with "-Wall -pedantic" no errors are emitted for the
> following code (at least with GCC).
>
... that is on a 32-bit or better Intel CPU, without the compiler
optimizations turned on. If it goes through the hardware's barrel
shifter, the shift count will be masked to the lower five or six bits
depending on the data size, as if you coded "a = b << ( c & 0x1f);".
Anyhow - that is my dead horse flogged for the day!
More information about the Chchrobotics
mailing list