Out-of-bounds pointers
Doug Davis
doug at letni.UUCP
Thu Oct 5 01:31:26 AEST 1989
In article <1009 at mtxinu.UUCP> ed at mtxinu.COM (Ed Gould) writes:
> void
> f() {
> char bug[100];
^^^^^^^^^^ I assume you mean buf here, right?
> char *p;
>
> p = buf;
>
> p--; /* p contains an illegal value: &buf[-1] */
^^^ Opps, You have now entered the land of illegal addresses,
normally called the twilight zone, incrementing the
pointer is no longer guarenteed to be == &buf[0], that
is installation dependent. Most likely it will == something
really weird and you get a core dump. Which one you get
is left as an exercise to the reader.
doug
__
Doug Davis/1030 Pleasant Valley Lane/Arlington/Texas/76015/817-467-3740
{sys1.tandy.com, motown!sys1, uiucuxc!sys1 lawnet, attctc, texbell} letni!doug
"ack, pifft! <ZOT> RRREEEEAAAAAWWWWOOOOOO!" -- Sound effects from the "Bill
The Cat'lprod(TM)" Commercial, Available in better hardware stores near you.
More information about the Comp.std.c
mailing list