I think that the following program ought to produce a run-time error but it doesn't. I have had a look at the GPC manual but I can't find any compiler directive that says Check array bounds, and I did rather think that the philosophy of Pascal was to prevent this sort of thing happening without the user having to take any special action. So, is there a way of generating the code that says 'Check array bounds' (I know other dialects of Pascal that do this by default).
Version 2.95.2 19991024 (release), running under RedHat 6.1, Cartman. Yes, I know it's old, but my version of VMWare won't work on the later kernels. ----------------- program arraytest(output); var i:integer; a,b:array[1..5] of integer; begin for i:=1 to 5 do a[i]:=i; for i:=1 to 10 do b[i]:=a[i]; for i:=1 to 20 do writeln(i,' ',b[i]); end. ------------------- The results file follows: -----------
1 1 2 2 3 3 4 4 5 5 6 1 7 2 8 3 9 4 10 5 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0
---------
John O.