Overflowchecking for non-native integer type broken
Original Reporter info from Mantis: FPCCore
-
Reporter name: FPC core team
Original Reporter info from Mantis: FPCCore
- Reporter name: FPC core team
Description:
Overflow-checking for non-native integer types are broken because FPC internally does all its calculations on native types (Tested with 2.0.0, can't select 2.0.0 in the drop down box of the bug entry form).
The given program should crash with an RTE, but does not.
The given code generates the following assembler output:
...
# [36] for i := 0 to 2000000 do begin
movl $0,U_P$PROGRAM_I
subl $1,U_P$PROGRAM_I
.balign 4
.L28:
addl $1,U_P$PROGRAM_I
# [37] inc(a);
movswl U_P$PROGRAM_A,%eax // <--- here
addl $1,%eax // <----- here!
jno .L31
call FPC_OVERFLOW
.L31:
movw %ax,U_P$PROGRAM_A
cmpl $2000000,U_P$PROGRAM_I
jl .L28
...
This is incompatible to Delphi too.
Additional information:
Reporter: Thomas Schatzl
EMail:
Mantis conversion info:
- Mantis ID: 5972
- OS: Win32
- Version: ?