Pred() with Word variables in for loops is incompatible to Delphi
Original Reporter info from Mantis: DRIGUS
-
Reporter name: DRIGUS GmbH
Original Reporter info from Mantis: DRIGUS
- Reporter name: DRIGUS GmbH
Description:
In FPC 2.4.1 Pred() in combination with Word variables in for loops behaves different as Delphi 5. Take a look at the following example:
procedure Test;
var
Count: Word;
I: Integer;
begin
Count := 0;
for I := 0 to Pred(Count) do
begin
WriteLn(I);
break;
end;
end;
FPC 2.4.1 goes into the for loop and print "0" to the output. Delphi 5 never go into the for loop. Using (Count-1) instead of Pred() solves it. But we have an amount of Delphi sources we tried to use in Lazarus and it is very difficult to find all relevant positions.
Steps to reproduce:
See the attached Lazarus console application.
Additional information:
Used Lazarus snapshot:
Lazarus 0.9.29 r26246
FPC 2.4.1
i386-win32-win32/win64
Mantis conversion info:
- Mantis ID: 16770
- OS: Windows
- OS Build: Windows XP
- Platform: i386
- Version: 2.4.1
- Fixed in version: 2.6.0
- Fixed in revision: 15474 (#04a63ea2)
- Monitored by: » DRIGUS (DRIGUS GmbH)