[fpc-devel] bitwise shift oddity a << b
lazarus at mfriebe.de
Tue May 19 15:19:44 CEST 2015
On 19/05/2015 13:56, Jonas Maebe wrote:
> On x86-64, x shr 64 = x, for any value of x. On i386, x shr 32 = x,
> for any value of x. For PowerPC (32 bit), x shr y = 0 if bit 5 of y is
> set, otherwise it's (x shr (y mod 32)). Really, there are very good
> reasons to treat this kind of stuff as undefined (unless you want to
> build a language for which the speed of compiled code is irrelevant).
> That's also why range/overflow checking exists as an option: to enable
> you to still catch such cases if you want, but to not burden all code
> all the time with these checks.
More information about the fpc-devel