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 wrote in message > news:373c0195 DOT 3902906 AT news DOT wanadoo DOT fr... > > On Mon, 10 May 1999 19:02:16 +1000, Chris Mears > > wrote: > > > > >Because you're overrunning the array. "int bit[63][6]" means that the > > >first index must be between 0 and 62 inclusive, and the second is > > >between 0 and 5, inclusive. I don't know why Visual C complains, but > > >the reason djgpp doesn't is because it trusts you. It assumes you know > > >what you're doing, and lets you do it uninhibited. > > > > > > > Many thanks, Chris, for the answer. > > I ought not to have forgotten that because it is very basic, but I was > > confused by the different reaction of DJGPP and MSVC. > > > > Gallicus.