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

P E Smee exspes at gdr.bath.ac.uk
Thu May 16 20:29:00 AEST 1991


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.
Pretending there was could get you into trouble.

Further, there's no reason to believe that (char *) 0 and 0L will be
the same on all future machines.  The standard doesn't require it.  All
the standard requires is that if you cast 0 to a pointer (something *)
0, the conversion will result in whatever bit pattern that machine/OS
uses as null pointers.  There are absolutely NO guarantees about what
that will look like internally -- if your code cares, then it is NOT
portable, and it WILL come back to haunt you (or your replacement)
someday.

-- 
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