[fpc-devel] Unexpected range check error (64-bit only)
Bart
bartjunk64 at gmail.com
Mon Jun 28 20:33:51 CEST 2021
Hi,
Something like this:
Int64 := Byte + Byte + (Signed integer type (8,16 or 32 bit) with
value < 0) will always give a range check error on X86_64 platform (if
range checking is enabled).
>From a mathematical POV, this can never give a range error, max value
would be 2147484157 (255 +255 High(int32)), min value would be
-2147483649 (0-High(Int32)).
At some point the negative integer is extended to a 64-bit value and
then tested to be <= High(Int64).
This of course will always fail, since the high bit will be set for
the negative integer (and comparion is unsigned).
Is this a consequnece of how fpc treats integer arithmetics (and thus
to be expected) or is this a bug.
If it is as designed, then why does the same not happen for
Int64 := Byte + (Signed integer type (8,16 or 32 bit) with value < 0)
nor for the 32-bit platform.
(Tested on Windows and Linux only with fpc 3.2.2 and fpc trunk)
--
Bart
More information about the fpc-devel
mailing list