Out of range pointers

Henry Spencer henry at utzoo.uucp
Sun Sep 25 07:20:50 AEST 1988


In article <1988Sep23.141042.23951 at sq.uucp> msb at sq.com (Mark Brader) writes:
>Henry Spencer (henry at utzoo.uucp), no less, replies:
>> The situation unfortunately isn't as symmetrical as it looks, because
>> a pointer to an array element points to the *beginning* of the array
>> element.
>
>He must not have gotten over his cold yet.  The correct statement is:
>a pointer to an array element *is typically implemented as* pointing to
>the beginning of the array element...

Mark, you might be surprised if you study the X3J11 drafts very closely.
Remember, for example, that a pointer to a struct, suitably cast, is
*required* to point to its first member.  Okay, you can say that the cast
can involve a conversion... but when you pay careful attention to the
rules about pointers to unions, such schemes start coming unravelled.
When you look very carefully at the combination of the rules for pointers
to structs, pointers to unions, pointers to arrays whose members are also
arrays, compatibility across separately-compiled modules, etc., it's very
hard to do seriously unorthodox things with pointers without breaking a
rule somewhere.
-- 
NASA is into artificial        |     Henry Spencer at U of Toronto Zoology
stupidity.  - Jerry Pournelle  | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list