On Feb 17, 2018, at 10:13 PM, Paul Isaacs <paul@redpineinstruments.org> wrote:
Hello all,
GPC 20060325 based on gcc-3.4.4
for i:= -1 to -1 do writeln( i );
produces: -1 0
Is this correct?
It isn't correct. If you look at the Pascal and Extended Pascal ISO standards paragraph 6.8.3.9 For-statements (same for both standards) you'll see the specification of a for statement has the following: Apart from the restrictions imposed by these requirements, the for-statement for v := e1 to e2 do body shall be equivalent to begin temp1 := e1; temp2 := e2; if temp1 <= temp2 then begin v := temp1; body; while v <> temp2 do begin v := succ(v); body end end end Thus, when the initial-value of the control-variable is equal to the final-value the for-statement body should be executed exactly one time. Gale Paeper gpaeper@empirenet.com