Marvin Humphrey wrote on 11/27/09 12:10 PM: > On Fri, Nov 27, 2009 at 09:04:27AM -0600, Peter Karman wrote: >> Not sure that this merits a JIRA ticket, but this little patch quiets a gcc >> warning: > >> #elif (SIZEOF_PTR == 8) >> - size_t address = self; >> + size_t address = (size_t)self; > > Hmm, is that 100% right? The existing code is definitely wrong and needs > fixing, but I can never remember all the ways that pointer-to-integer and > integer-to-pointer conversion can go screwy. There are some really weird > truncation effects on some systems. > > Probably what we ought to do is rely on macros *every* time we need to convert > between integers and pointers. The conversion macros would be implemented in > Charmonizer and would get thorough testing. > > There's already a PTR2I64 macro in Charmonizer/Probe/Integers, but we probably > need a larger menu: > > PTR2I64 > PTR2U64 > PTR2I32 > PTR2U32 > PTR2SIZET >
sounds reasonable. Should pointers always be converted to unsigned types? Seems like it. So in the example above, with the macro it becomes: chy_u64_t address = PTR2U64(self); ? -- Peter Karman . http://peknet.com/ . [email protected]
