Message-ID: <37388E96.A4BDB21A@pallen.dabsol.co.uk> Date: Tue, 11 May 1999 21:09:58 +0100 From: Peter Allen
X-Mailer: Mozilla 4.04 [en] (Win95; I)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: ? array[n] or array[n+1] ?
References: <37367f71 DOT 6271443 AT news DOT wanadoo DOT fr> <3736A098 DOT 55E268BE AT softhome DOT net> <373c0195 DOT 3902906 AT news DOT wanadoo DOT fr> <3737f542 DOT 0 AT nnrp1 DOT news DOT uk DOT psi DOT net>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Reply-To: djgpp AT delorie DOT com
It's often impossible to catch such things, as very often
which element of the array is going to be accessed is determined
at run time not compile time. Bounds checking at run time is very
expensive in terms of program efficency, and is only usually done in
high level languages, such as basic. C is not a "beginners language",
it drops you straight in at the deep end.
Peter Allen
Ya'qub wrote:
>
> Greetings,
> With all due respect, this explanation does not seem very convincing.
> Surely, the compiler *should* complain when you do such a thing as
> overrunning an array. I hoped that the compiler would help such a poor
> programmer as myself in catching such bugs which I suppose could cause quite
> a lot of headache to locate. Can anybody else confirm that gcc makes such
> assumptions that we know what we are doing and let us carry on regardless.
> Also, out of curiosity, if you do overrun an array and the program has
> compiled without any warning or error, is there anything that can be said
> about its execution? i.e. do we know what is going to happen when the
> program tries to access an element from the array beyond its length. Thanks
> Regards,
> Ya'qub
>
> Gallicus