[fpc-devel] Unexpected range check error (64-bit only)

Bart bartjunk64 at gmail.com
Sat Jan 1 13:01:01 CET 2022

On Thu, Dec 30, 2021 at 1:05 PM Jonas Maebe via fpc-devel
<fpc-devel at lists.freepascal.org> wrote:

> > Nor why it only triggers with Byte + Byte + Unsigned, and not with
> In you original mail, you said it triggered for Byte + Byte + Signed.

Yes, of course, the original mail is correct.

> It doesn't trigger for Byte + *Signed* because that expression gets
> evaluated as a signed expression

OK, let me see if I understand it correctly now:

1. (Signed) Int64 :=  unsigned(32-16-8bit) + unsigned(32-16-8-bit) +
gets evaluated with unsigned 64-bit arithmetic and then the test for
<high(signed 64-bit) fails.

2. (Signed) Int64 := unsigned(32-16-8-bit) + signed(32-16-8-bit)
gets eval with signed arithmetic.

How to workaround (1) then, other then turning range checking off?
(Since I hardly ever trust myself, almost all of my applications ahve
range checking on even in release mode.)

And the consequence is that even if we eventually have native 128-bit
integer support, the problem will persist but now for Int128?

Annoying it is.


More information about the fpc-devel mailing list