Mail Archives: djgpp/1999/05/12/19:15:30
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
- Raw text -