Casting Function Pointers

David Fiander david at sco.COM
Tue May 28 22:49:30 AEST 1991


In article <1991May27.153520.4547 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
>In article <16271 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>>>I know of at least one -- it's no longer promised that casting a pointer to
>>>integer and back preserves its value if the integer is big enough...
>>
>
>I don't have them handy either.  I remember noticing that the "you can do
>this" promise had disappeared, but I have no idea when it was.
>
>Probably something to do with the AS/400. :-)

>From what you've (or was it doug) said, that wouldn't surprise me, but
the same thing happens on the CDC Cyber series, and probably on the Prime
9600 series (I can't check, it's not up right now).  These machines use
rings for protection and, on the Cybers, converting from a pointer to an
int may be all right, but converting from an int to a pointer zeros the
ring bits in the pointer created.  This caused us all sorts of problems,
because the test

	p == (char *)-1

will have a different result from the test

	(int)p == -1

malloc broke because of this, and it took us two or three 12-hour days to
figure it out.

--
David J. Fiander
SCO MMDF Development Team
SCO Canada, Inc.



More information about the Comp.std.c mailing list