Invalid pointer addresses

Henry Spencer henry at utzoo.uucp
Sat Sep 10 02:44:19 AEST 1988


In article <12088 at steinmetz.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>  I recently proofread a manual which stated that even calculating the
>value of an invalid address could cause a memory fault...

This is correct.  On single-linear-address-space machines, computing an
invalid address just generates a meaningless number.  On machines with
segments, an address is a structured object:  if the address you start
with is <segment 456, offset 10> and you try to subtract 20 from it,
this may be considered a meaningless and illegal operation -- a kind of
underflow -- rather than a legal operation generating meaningless results.
It depends on whether the designers were segment purists or not, and on
precisely how they defined the format of an address and the semantics
of arithmetic on it.

>... Is there a portion of dpANS which states that this is/isn't
>allowed, or that it's implementation dependent? ...

If you study the section on pointer arithmetic, you will find that, with
the single exception of a pointer one past the end of an array (not its
beginning!), *any* pointer arithmetic which takes you out of the array
you started in is allowed to send you off into the twilight zone.

Analogies to NULL are invalid; NULL is a special case of a legal pointer
which you are not allowed to dereference.
-- 
Intel CPUs are not defective,  |     Henry Spencer at U of Toronto Zoology
they just act that way.        | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list