[fpc-pascal]range-checking observations and questions
andy at nospam.com
Fri Oct 3 00:19:13 CEST 2003
Apparently, activating -Cr is needed to enable enforcement of
compile time constant range checking as well.
The ff. program:
E: array[2..4] of Integer;
will compile albeit with a warning. Only when -Cr is enabled
will the range violation become an error. Is this kind of freedom
intentional and will it serve certain purposes?
For arrays of characters, the range checking is even looser.
I have noticed that the ff range violation:
D: array[2..4] of char;
is completely ignored whether -Cr is enabled or not. No
error, no warning.
Will such code result in memory corruption somewhere in both the
cases where runtime range checking is enabled and the one where
it is not enabled?
Is this something that needs to be fixed or is there a
philosophy/explanation behind this behaviour?
Is this a special case for char arrays/strings only and will
never happen with other types?
Note: I am using FPC 1.0.10
More information about the fpc-pascal