Mill Computing, Inc. Forums The Mill Tools Compilers Getting an int from a possible pointer Reply To: Getting an int from a possible pointer

Ivan Godard
Keymaster
Post count: 689

I like your handle.

Pointers are data like any other, and can be in the stack frame. What is not in the Mill stack frame is the state of the calling protocol, in particular the return address and down-stack link. These may be machine addresses (and usually are) but are not program-declared pointers.

Mill conforms to C rules, which permit conversion between pointer types and intptr_t integral. However, the only thing you can legally do with the result of a conversion is to convert it back again. The facility exists to support data structures that need a hash or total ordering of pointers.

You can legally modify the low bits either by converting to integer and doing integer arithmetic, or by casting through void* to char[4] and doing pointer arithmetic.