grunwald@flute.cs.uiuc.edu (Dirk Grunwald) (01/19/89)
It used to be that macho C and C++ programmers would automatically convert any array-striding code into a pointer-following mess, in the name of efficient code. Needless to say, this is what good compilers are for, particular compilers with -fstrength-reduce. One of my biggest beefs with C++/C is that there is NO WAY to check array reference indicies automatically, even if you're using array indicies. In general, you don't always know the size of the array, however, often, you *do* know the size of the array, either at run-time or compile time. What I'm proposing is yet another addition to the wish list: array bounds checking and bounds specification. Bounds checking is simple: if you know the size of the array at compile time, just check the array index. Bounds specification is tricker: If there isn't a general format, I would propose #pragma array bounds <name> [<bounds0>][<bounds1>] etc... where <bounds0>, <bounds1> etc can be expressions, not just constants. This bounding information could also be passed to GDB via the symbol table. Obviously, this isn't a cure-all for older code, but for paranoid people who write new code & want it to be easier to debug, I'd really like to see this. [ I just took a quick survey -- three C hackers said ``yes, this is needed'' ]