Hello all,
GPC 20060325 based on gcc-3.4.4
for i:= -1 to -1 do writeln( i );
produces: -1 0
Is this correct?
Thanks,
Paul Isaacs
Le 18/02/2018 à 07:13, Paul Isaacs a écrit :
Hello all,
GPC 20060325 based on gcc-3.4.4
for i:= -1 to -1 do writeln( i );
produces: -1 0
Is this correct?
NO
for me GPC 20070904 based on GCC-3.4.5 (MinGW) it produces correctly only
-1
Hope this helps
Maurice Lombardi
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
On 18/02/18 01:13 AM, Paul Isaacs wrote:
Sorry. Double checked with simple test program. It worked correctly.
My apologies. I should have been more careful.
Regards,
Paul Isaacs
Hello all,
GPC 20060325 based on gcc-3.4.4
for i:= -1 to -1 do writeln( i );
produces: -1 0
Is this correct?
Thanks,
Paul Isaacs
Gpc mailing list Gpc@gnu.de https://www.g-n-u.de/mailman/listinfo/gpc