Frank Heckenbach wrote:
... snip ...
CBFalconer wrote:
Chiming in with a 'me too'. What is needed is a way to check expressions as they are built, and prior to storing or using to index. It should look something like "check(min,max):boolean" This can be applied to subranges and indices, in fact whereever the compiler has knowledge of extreme allowable values (this includes case indices). If the machine model is a stack machine the model for this is easy.
In the long run the efficiency aspects can be ameliorated by deciding where NOT to call the checking code. This is where the numeric analysis comes in.
For arrays one of the preliminary operations is always to subtract the lower bound, so this can be combined with the check operation. Or you can look at it as being a check of a single value after manipulating into something zero based, but I think the lack of generality there will bite sooner or later.
Sorry, but we've discussed all these issues before, so let me point out again (and hopefully for the last time):
I know quite well which cases need checking, on the source level. But it's some work to find the places in the compiler.
We don't want a function. Doing the comparison inline is easy, more efficient (and maybe even smaller WRT code size; I'm not sure and I don't care too much).
We don't need to worry about low-level optimization. The backend does this perfectly well already.
Please don't don't consider anything sent to the mail list a criticism, or as addressed to you in particular. I certainly consider it as something for public consumption. You are much more familiar with the inner workings than anyone else I know, but obviously are not going to do everything. Mutterings about the general problems can sit in the rear of the mind of whoever eventually does something, and may very well help to gel his or her thoughts.
The last thing anyone should do is roll up their sleeves and start typing in code without a general attack clear.