Path: 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 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.