Out-of-bounds pointers

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Sat Oct 7 02:07:06 AEST 1989


In article <12570028 at hpclwjm.HP.COM>, walter at hpclwjm.HP.COM (Walter Murray) writes:

|  Doug Gwyn:
|  
|  > It's not even "legal" to compute an invalid address, whether or not
|  > it is dereferenced.

  While this is obviously true, I have never understood the rationale of
this decision. Given that (a) there are existing programs which do this,
for reasons other than sloppy programming, (b) most implementations
happily allow this, and (c) if you are allowed to declare an auto
pointer at all then obviously the hardware supports uninitialized
pointers, I fail to see what benefit is gained.

  Yes, I do understand the diference between calculating such a pointer
and dereferencing it, and obviously dereferencing it is obviously
non-portable.

  The only reason I have heard is the argument that there might be (or
is) a machine such that (a) it checks addresses stored in address
registers when stored, (b) the checking can't be turned off by software,
and (c) the machine is incapable of storing the address in memory or any
other pointer and loading it into the pointer register only when
dereference is needed.

  Could someone clarify this, since it certainly is not prevailing
practice? 
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.std.c mailing list