Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!munnari.oz.au!metro!wolfen!hls0!george From: george@hls0.hls.oz (George Turczynski) Newsgroups: comp.lang.c Subject: Re: Array bounds checking with C???? Summary: `C' is fine just as it is. Message-ID: <856@hls0.hls.oz> Date: 30 Aug 90 01:04:04 GMT References: <7611@ucdavis.ucdavis.edu> Lines: 34 In article <7611@ucdavis.ucdavis.edu>, kuan@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@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 |----------------------------------------------------