pointer sizes, was: Re: What does char **ch mean?

P E Smee exspes at gdr.bath.ac.uk
Thu May 16 23:28:55 AEST 1991


In article <1991May16.102900.13063 at gdr.bath.ac.uk> P.Smee at bristol.ac.uk (Paul Smee) writes:
>In article <wolfram.674309645 at akela> wolfram at akela.informatik.rwth-aachen.de (Wolfram Roesler) writes:
>>gwyn at smoke.brl.mil (Doug Gwyn) writes:
>>
>>>>that the declaration char **ch; is equivalent to char *ch;
>>>No, they're not at all equivalent.  They might not even have the same size.
>>                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>>I advised somebody something similar to that, telling him (like I learned
>>from the FAQ) that weird machines have weird pointers, that (char*)0 and
>>0L might have different binary representations and the like. His response
>>to this was:
>>	"I claim there are no machines like this"
>>What do you gurus say about this? How about an example of a machine or OS
>>where this is true?
>
>Don't know about current machines, but certainly on Multics (which
>hasn't been dead for that long) there was absolutely no resemblance
>between the null pointer (char *) 0, and any other form of 0.

Apropos current machines, I just recovered my copy of 'Portable C and
Unix System Programming' by J.E. Lapin (a pseudonym) of Rabbit Software
Corp.  (A handy book, by the way, everyone should have one.
Prentice-Hall, ISBN 0-13-686494-5.)  It says:

    On processors such as the 8086, the representation of a null
    pointer may differ from the arithmetic (integer sized) constant 0.
    On the 68000, code generation that exploits the difference between
    data and address registers may break code that expects the null
    pointer to be identical to an integer 0.

-- 
Paul Smee, Computing Service, University of Bristol, Bristol BS8 1UD, UK
 P.Smee at bristol.ac.uk - ..!uunet!ukc!bsmail!p.smee - Tel +44 272 303132



More information about the Comp.lang.c mailing list