The following was initially discovered by Gale Paeper.
[g5:~/gpc/testgpc/adriaan] adriaan% cat rangecheck1.p
program rangecheck1; var i: 1..5; begin i:= 5; {$local R-} i:= i+1; {$endlocal} i:= 4; i:= i+2; writeln( 'i = ', i); end.
[g5:~/gpc/testgpc/adriaan] adriaan% gpc41 rangecheck1.p --range-checking [g5:~/gpc/testgpc/adriaan] adriaan% ./a.out i = 6
[g5:~/gpc/testgpc/adriaan] adriaan% cat rangecheck2.p
{$R+} program rangecheck2; var i: 1..5; begin i:= 5; {$local R-} i:= i+1; {$endlocal} i:= 4; i:= i+2; writeln( 'i = ', i); end. [g5:~/gpc/testgpc/adriaan] adriaan% gpc41 rangecheck2.p --range-checking [g5:~/gpc/testgpc/adriaan] adriaan% ./a.out ./a.out: value out of range (error #300 at 2487)
[g5:~/gpc/testgpc/adriaan] adriaan% cat rangecheck3.p
{$R+} program rangecheck3; var i: 1..5; begin i:= 5; {$local R-} i:= i+1; {$endlocal} writeln( 'i = ', i); end. [g5:~/gpc/testgpc/adriaan] adriaan% gpc41 rangecheck3.p --range-checking [g5:~/gpc/testgpc/adriaan] adriaan% ./a.out i = 6
[g5:~/gpc/testgpc/adriaan] adriaan% cat rangecheck4.p
{$R+} program rangecheck4; var i: 1..5; begin i:= 4; i:= i+2; writeln( 'i = ', i); end. [g5:~/gpc/testgpc/adriaan] adriaan% gpc41 rangecheck4.p --range-checking [g5:~/gpc/testgpc/adriaan] adriaan% ./a.out ./a.out: value out of range (error #300 at 2477)
[g5:~/gpc/testgpc/adriaan] adriaan% gpc41 -v Using built-in specs. Configured with: ../gcc-4.1.0/configure --enable-languages=c,pascal --enable-threads=posix --target=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --build=powerpc-apple-darwin8 --prefix=/Developer/Pascal/gpc410d1 Thread model: posix gpc version 20060325, based on gcc-4.1.0
In other words, {$local R-} disables range-checking for the rest of the file when using --range-checking as a command-line option, not when using {$R+}. I can hardly imagine this is intended behaviour.
Regards,
Adriaan van Os