Range check error when using a for-loop with highest unsigned bound
Original Reporter info from Mantis: PascalDragon @PascalDragon
-
Reporter name: Sven Barth
Original Reporter info from Mantis: PascalDragon @PascalDragon
- Reporter name: Sven Barth
Description:
I'm trying to use a for-loop with a LongWord as counter variable and High(LongWord) as highest bound.
E.g.
var
i: LongWord;
begin
for i := 0 to High(LongWord) do
;
end;
This fails with "range check error while evaluating constants".
Using Word as counter and upper bound works and QWord fails as well.
Additional information:
Attached example uses three different unsigned types (Word, LongWord, QWord) and uses three different ways of setting the upper bound (for Word: High(countervar), High(Word) and Word($FFFF)).
Output is the following:
====
fpc forrangecheck.pas
Free Pascal Compiler version 2.4.0 [2010/01/01] for i386
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for i386
Compiling forrangecheck.pas
forrangecheck.pas(12,5) Error: range check error while evaluating constants
forrangecheck.pas(14,7) Error: Ordinal expression expected
forrangecheck.pas(15,5) Error: range check error while evaluating constants
forrangecheck.pas(21,5) Error: range check error while evaluating constants
forrangecheck.pas(23,7) Error: Ordinal expression expected
forrangecheck.pas(24,5) Error: range check error while evaluating constants
forrangecheck.pas(30,5) Error: range check error while evaluating constants
forrangecheck.pas(32,7) Error: Ordinal expression expected
forrangecheck.pas(33,5) Error: range check error while evaluating constants
forrangecheck.pas(35) Fatal: There were 9 errors compiling module, stopping
Fatal: Compilation aborted
Error: /home/sven/.bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
====
Range checking is disabled (I also checked .fpc.cfg). The example fails with FPC trunk from around end of August as well.
Mantis conversion info:
- Mantis ID: 17646
- OS: Linux
- OS Build: 2.6.34
- Platform: i386
- Version: 2.4.0
- Fixed in version: 2.6.0
- Fixed in revision: 16213 (#14b95b3b)