Article View: comp.std.c
Article #666Re: Out-of-bounds pointers
From: Scott Amspoker
Date: Thu, 05 Oct 1989 17:20
Date: Thu, 05 Oct 1989 17:20
27 lines
1491 bytes
1491 bytes
In article <4199@letni.UUCP> doug@letni.LawNet.Com (Doug Davis) writes:
>In article <1009@mtxinu.UUCP> ed@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.
Agreed, it is undefined. However *most likely* it will work just fine (based
on the several dozen systems I've worked with). I would recommend avoiding
it though.
--
Scott Amspoker
Basis International, Albuquerque, NM
(505) 345-5232
Technical Details
Message-ID:
<202@bbxsda.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!unmvax!bbx!bbxsda!scottReferences:
<1009@mtxinu.UUCP> <4199@letni.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!unmvax!bbx!bbxsda!scott From: scott@bbxsda.UUCP (Scott Amspoker) Newsgroups: comp.std.c Subject: Re: Out-of-bounds pointers Message-ID: <202@bbxsda.UUCP> Date: 5 Oct 89 17:20:24 GMT References: <1009@mtxinu.UUCP> <4199@letni.UUCP> Reply-To: scott@bbxsda.UUCP (Scott Amspoker) Organization: Basis International, Albuquerque, NM Lines: 27