negative addresses

Doug Gwyn gwyn at brl-smoke.ARPA
Thu May 19 00:36:26 AEST 1988


In article <3504 at pasteur.Berkeley.Edu> faustus at ic.Berkeley.EDU (Wayne A. Christopher) writes:
>In article <10001 at tekecs.TEK.COM>, andrew at frip.gwd.tek.com (Andrew Klossner) writes:
>> 		if (tbuf->c_ptr)
>The trick here is that whenever a pointer is converted into an
>integer (as here), the NULL pointer must be converted to the integer
>0.  It doesn't matter what the bit pattern is before conversion.

You got the right answer by the wrong reasoning.
The pointer is NOT converted to an integer.
This partial-statement is fully equivalent to
	if (tbuf->c_ptr != 0)
and the integer constant 0 is guaranteed to
be comparable to a null pointer.  How this is
accomplished is the implementor's business,
and does NOT imply that a null pointer of a
given type (there are different pointer types!)
is represented in a way that "looks like" the
representation of integer value 0.



More information about the Comp.lang.c mailing list