From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: ? array[n] or array[n+1] ? Date: Wed, 12 May 1999 17:36:21 -0400 Organization: BrunNet Lines: 33 Message-ID: <3739F455.1818FDD7@unb.ca> 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> NNTP-Posting-Host: ftnts2c44.brunnet.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.51 [en] (Win95; U) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 Outcome #1: If you access some protected memory (on a machine that supports it, like with DJGPP or Win32) that is outside one of the 2K banks assigned to you, there will be a GPF and your program will nicely terminate. Outcome #2: If you access some of your memory that is associated with some other variable or code, your program may run perfectly, or may suffer some strage effects. Outcome #3: Something terrible might happen. Worst case scenario (never known anyone it has happened to, but it's possible): overwriting some buffered portion of a hard-drive or memory mapped io could desroy data or hardware. -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT HotMail DOT com ICQ: 32959047