[fpc-devel] Division nodes

Kirinn kirinn at mooncore.eu
Mon May 15 18:43:35 CEST 2023


I didn't see a mention of it in this discussion thread, but dividing the
largest negative integer by -1 does cause an overflow error of some sort,
because of two's complement.

Just to make sure, do (min_int div -1) and (min_int mod -1) behave the same
way before and after this proposed change? And, what min_int is of course
depends on whether targeting a 32-bit or 64-bit system, so best check both
cases.

~Kirinn

On Mon, 15 May 2023 17:21:30 +0100
"J. Gareth Moreton via fpc-devel" <fpc-devel at lists.freepascal.org> wrote:

> I made a merge request that removes the comparison against -1. 
> x86_64-win64 and i386-win32 pass without any regressions, so the reason 
> behind the change still eludes me.  Maybe my fix for #39646 removes the 
> need for it?
> 
> https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/418
> 
> Kit
> 
> On 11/05/2023 23:04, J. Gareth Moreton via fpc-devel wrote:
> > Fair enough, but I would like an explanation as to why it's necessary, 
> > because the reason for testing -1 in particular is very unclear, and I 
> > wonder if there's a known misbehaviour with a particular division 
> > function with -1.
> >
> > Kit


More information about the fpc-devel mailing list