Rangecheck triggers on overflow but Overflow check does not trigger, moreover -CR option generates range check code while $OBJECTCHECKS directive doesn't
Version: main branch (3.3.1-9981-gd5d97169), x86-64 Linux
Consider this code:
program project1;
{$RangeChecks On}
var
A, B: UInt32;
begin
A := $FFFFFFFF;
B := 1;
A += B;
WriteLn(A);
end.
This should (IMHO) not trigger a range check but an overflow check instead.
- it will trigger a range error if range checks are enabled, either with
{$RANGECHECK ON}or with-Cr - it will NOT trigger an error if overflow checks are enabled, neither with
{$OVERFLOWCHECKS On}nor with-Co.
Even more confusing is it will also trigger with -CR, when I enable -CR option on the commandline it will generate code for range- and overflow checks and trigger a range error while when enabling the same with the {$OBJECTCHECKS ON} directive instead it won't trigger.
Edited by Bernd K.