by breadbox · 12y ago · 0 comments
IIRC, you can do this just by checking if it is less than zero.
tl;dr: all valid pointer values are possible, regardless of how much memory you actually have.
And, when you get down to the assembly level, it doesn't matter - you can treat an unsigned integer as signed for a comparison if it makes things easier.
That may be rare nowadays (or is it? I remember reading recently that some 64-bit CPU chose to preferably use a memory range from -2GB to +2GB. AMD64?), but whether there is is outside of the control of most language implementers. They can control their own memory allocator, though, and guarantee that it never stores 64-bit quantities at odd addresses.