Hi,
after some friendly requests and discussion, I'm planning to implement range checking as one of the next major things in GPC (probably in Januaray, if nothing urgent gets in between ...).
Note, I'm using "range checking" in the specific meaning I explained recently, not generally for all kinds of runtime checks, and not including overflow checking of arithmetic operations etc. (that will be a separate issue).
Also, as I said before, I'll do an "easy" implementation. I'm still not convinced that anything more is worth the (big) effort when the programmer in the rare (AFAICS) cases where it matters could just as well use explicit types etc. to avoid checks where he doesn't want them.
Since some of you have said they'd like to help, but can't code in the compiler itself, here are at least 2 chances:
1. Help finding all places where range checking must be applied
In mean this from a Pascal point of view, covering, of course, all standards, dialects and extensions that GPC supports. So far I've found the following ones:
- assignment to variables and function results,
- value parameter passing to user-defined and built-in (e.g., `Chr', `FillChar', ...) routines,
- array indexing (R/W),
- array slice indexing (R/W),
- `for' loop bounds,
- conformant array range,
- actual schema discriminants,
- initialization of types, variables and typed constants,
- `asm' targets
2. Write test programs
Test programs should follow the guidelines in the manual. In particular, since most of the tests will check for errors, each one must be a separate test for each situation (each of the cases above plus any that others of you will come up with). For a way to test runtime errors see, e.g., fjf424d.pas.
Range checking will be on by default, and can be switched on/off with the options `--[no-]range-checking' and the compiler directives `{$[no-]range-checking}', and `{$R+}', `{$R-}'. A complete set of tests should also test all of those.
If you'd like to do so, please post a short note, so several of you won't duplicate efforts, but can coordinate.
Frank