Pointer comparison and Portability

Schauble at mit-multics.arpa Schauble at mit-multics.arpa
Thu Feb 19 20:22:26 AEST 1987


Unfortunately, the Intel 8086 series provides another counter example.
On this machine, address are in the form of segment and offset.  The
Actual Address is 16*segment + offset.  This is usually written as
segment:offset.  Thus, the two pointers 0100:0010 and 0101:0000 point at
the same byte.  If compared, they will *NOT* compare equal.

So, if two pointers compare equal, they definately point at the same
object.  However, the converse is not true.  Two pointers that do not
compare equal do NOT (necessarily) point at different objects.

Seems like when K & R says that pointer comparison is undefined except
when the two are pointers to the same array, it should be taken to mean
exactly that for all operators, including == and !=.

          Paul
          Schauble at MIT-Multics.arpa



More information about the Comp.lang.c mailing list