For loops initial value out of range

Official Description For a for-statement, it is an error if the value of the initial-value is not assignment-compatible with the type possessed by the control-variable, if the statement of the for-statement is executed.

Simplified Description

In other words, it is an error if the following two conditions are met:

For example given:

   type num = 1..100;
   var n : num;

then the following are errors:

   for n := 0 to 100 do writeln(n);
   for n := 101 downto 1 do writeln(n);

But the following are not errors since the for loops are never started (and therefore no assignments are made to n).

   for n := 101 to 1 do writeln(n);
   for n := 0 downto 100 do writeln(n);

Error Handling

This error is reported if range checking is enabled.