🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3080

Re: Casting Function Pointers

#3080
From: Theo Norvell
Date: Tue, 28 May 1991 19:09
21 lines
1299 bytes
In article <1991May28.124930.19893@sco.COM> david@sco.COM (David Fiander) writes:
>>In article <16271@smoke.brl.mil> gwyn@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...
>>>
>on the Cybers, 
>
>	p == (char *)-1
>
>will have a different result from the test
>
>	(int)p == -1
>

It would be a bit much to expect there to be a bijection between 48 bit
pointers and 64 bit integers.  On recent 180 C compilers
	p == (char *)(int)p
which is what Doug was talking about.  The value is preserved, even if the
representation is not.  This is because pointer comparison ignores ring
numbers -- it has to or two pointers to the same object could
compare as different.
Technical Details
Message-ID: <1991May28.150947.13420@jarvis.csri.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!csri.toronto.edu!norvell
References: <1991May25.221756.16182@zoo.toronto.edu> <16271@smoke.brl.mil> <1991May27.153520.4547@zoo.toronto.edu> <1991May28.124930.19893@sco.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!csri.toronto.edu!norvell
Newsgroups: comp.std.c
From: norvell@csri.toronto.edu (Theo Norvell)
Subject: Re: Casting Function Pointers
Message-ID: <1991May28.150947.13420@jarvis.csri.toronto.edu>
Organization: CSRI, University of Toronto
References: <1991May25.221756.16182@zoo.toronto.edu> <16271@smoke.brl.mil> <1991May27.153520.4547@zoo.toronto.edu> <1991May28.124930.19893@sco.COM>
Date: 28 May 91 19:09:47 GMT
Lines: 21