Array bounds checking with C????
George Turczynski
george at hls0.hls.oz
Thu Aug 30 11:04:04 AEST 1990
In article <7611 at ucdavis.ucdavis.edu>, kuan at iris.ucdavis.edu (Frank [Who me?] Kuan) writes:
>
> Why is it that most C compilers don't seem to support this
> nifty little feature?
Because most C compilers assume you know what you're doing :-)
> I'm working on a large project, and two of the worst debugging
> nightmares I've had were due to memory being overwritten from
> over indexing an array.
Array bounds, along with typos, should be one of the first things you
check when looking for (discrete) bugs, though I guess you know that
now !
> I was thinking about writing some kind of preprocessor to
> check for this. Has anyone already written something like
> this?
What is it that you want ? Something to check your array indexing
variables at compile-time ? In most cases, this is _possible_, but in
others it's impossible. If you want code generated to check array
indexing at run-time, then your code will run slower, which is why
C compilers don't do it. We want the fastest possible code we can
get !
If you want these sorts of features, use PASCAL :-)
--
| George P. J. Turczynski. |----------------------------------------------------
| Computer Systems Engineer. | ACSnet: george at highland.oz | I can't speak for the |
| Highland Logic Pty. Ltd. | Phone: +61 48 683490 | company, I can barely |
| Suite 1, 348-354 Argyle St | Fax: +61 48 683474 | speak for myself... |
| Moss Vale. NSW. Australia. 2577 |----------------------------------------------------
More information about the Comp.lang.c
mailing list