Thorsten Glaser wrote:
Adriaan van Os dixit:
But I don't know if the stack detector automatically also works for Pascal (maybe Waldek can say).
I disabled it for Ada because they have their own system (which even conflicts with it), but didn't do it (yet) for Pascal, because I don't know if it can catch some (corner?) cases which the integrated checks (like {$R+,S+} etc.) don't find. I'm waiting for a response from the GPC wizards regarding this ;)
For Extended Pascal range checking should catch all out of range indices, hence all buffer overflows. If some is not detected then this is a compiler bug. But gpc has bugs, so I would not exlude possibility of bug in range checking.
More important is that gpc allows various extensions and inline directives. {$R-} turns range checking off. {$pointer-arithmetic} turns on C-like pointer arithmetic. Also, gpc range checking assumes that inputs are in range, so for example in the program below:
program arrb; type ind = 1..5; var t: array [ind] of char; i : ind; function i20 : integer; begin i20 := 20; end; begin {$R-} i := i20; {$R+} t[i] := 'a'; end.
out of range access is not detected. So, gpc make checking convenient, but there is still a lot of room for human errors.