<snip> while 64-bit gives ERangeError: Range check error (RTE 201). That's with explicit -Cr given, otherwise none gives RTE.IMO, that's a bit of a problem. In 32bit, the overflow is detected just by enabling overflow checking whereas in 64bit, enabling overflow checking isn't enough even though it should be.
That makes the compiler's behavior inconsistent. In one case (32bit), the overflow is detected by enabling overflow checking and in the other case (64bit) the overflow is detected only by enabling a different check, specifically, range checking.I agree. This is due to the implementation of the overflow check method.
Overflow checking should be enough in either bitness.
By the way, Delphi (32 or 64) always use such code:Delphi's method is the inherently correct way of checking for and handling an overflow.Which outputs IntOverflow regardless of bitness.
Project15.dpr.12: R := -R; // should cause an overflow neg dword ptr [$004278dc] jno $0041f5d5 call @IntOver
Please report in bugtracker.The reason I didn't is because I'm not sure the FPC developers will consider it a bug. My guess is, they'll simply say to use range checking in addition to overflow checking.
Please report in bugtracker.The reason I didn't is because I'm not sure the FPC developers will consider it a bug. My guess is, they'll simply say to use range checking in addition to overflow checking.
That said, if one of the developers considers it a bug, I'll gladly report it as such.