[comp.lang.c++] offsetof, pointer to member.

diamond@tkou02.enet.dec.com (diamond@tkovoa) (04/09/90)

In article <10677@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes:
>In article <1431@tkou02.enet.dec.com>, diamond@tkou02.enet.dec.com (diamond@tkovoa) writes:
>>In article <26191B56.143@paris.ics.uci.edu> rfg@ics.uci.edu (Ronald Guilmette) writes:
>>>
>>>The reason is that this is a clever way of reserving the value 0 for use
>>>as a *NULL* for pointer-to-data-member types.
>>
>> Interesting.  However, would it not be equally clever, and faster in CPU
>> time, to reserve the value -1 for that purpose instead?
>
>In both C and C++, 0 is the only pointer value that is guaranteed
>to be distinct from the address of any object.
>It would be decidedly weird to do something inconsistent with
>that for pointers to members.

I can hardly believe my eyes.  Andrew Koenig confused a null pointer
with a run-time entity of all-bits-0 ?

As a matter of internal implementation and efficiency, all-bits-1
(on two's complement machines anyway) seems better, so that games
don't have to be played with the representations of actual offsets.






-- 
Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
This_blank_intentionally_left_underlined________________________________________