if(p)

Guy Harris guy at sun.uucp
Thu Oct 17 19:22:47 AEST 1985


> What's wrong with this? It's identical to "if(p==(foo *)i)" according to the
> default expression evaluation rules. Any special meaning of 0 should be
> handled in the evaluation of (foo *)i.

No, it shouldn't.  According to K&R, the rules for conversion between
pointers and integers are machine-dependent but are supposed to be
"unsurprising".  I'd be surprised as hell if, assuming a null pointer had
some value other than all zero bits, this conversion produced a null pointer
if i is zero.  K&R takes great pains to insist that the interpretation of 0
as a null pointer is only to be taken if the 0 is a *constant* 0.

	Guy Harris



More information about the Comp.lang.c mailing list