regcmp()

Richard Tobin richard at aiva.ed.ac.uk
Tue Feb 23 08:04:41 AEST 1988


In article <15100006 at bucc2> brian at bucc2.UUCP writes:
>> Not if you cast it to "char *", it isn't!  Passing "(char *)0" is quite
>> sufficient, unless the compiler is horribly broken.
>  Tsk, tsk, tsk. This statment is true if sizeof(int) == sizeof(pointer).

It certainly is.  It's also true if sizeof(int) != sizeof(pointer).

The way you get a null character pointer is by casting 0 to (char *).
If a compiler doesn't take (char *)0 to be a null character pointer,
it's broken, regardless of the length of pointers.  That's just the way
it is.

Casting 0 to (char *) is *NOT* defined to pretend that zero bit-pattern is
a pointer, it's defined to to *convert* 0.  The resulting bit pattern can
be anything at all (it's often zero).  All that matters is that it's
always the same, and that no object has it as its address.

-- Richard
-- 
Richard Tobin,                         JANET: R.Tobin at uk.ac.ed             
AI Applications Institute,             ARPA:  R.Tobin%uk.ac.ed at nss.cs.ucl.ac.uk
Edinburgh University.                  UUCP:  ...!ukc!ed.ac.uk!R.Tobin



More information about the Comp.unix.questions mailing list