Newsgroups: comp.std.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Invalid pointer addresses
Message-ID: <1988Sep9.164419.12461@utzoo.uucp>
Organization: U of Toronto Zoology
References: <12088@steinmetz.ge.com>
Date: Fri, 9 Sep 88 16:44:19 GMT

In article <12088@steinmetz.ge.com> davidsen@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@zoo.toronto.edu
