...
Do not convert a pointer type to an integer type if the result cannot be represented in the integer type. (see See undefined behavior 24.).
The mapping between pointers and integers must be consistent with the addressing structure of the execution environment. Issues may arise, for example, on architectures that have a segmented memory model.
...
Any valid pointer to void
can be converted to intptr_t
or uintptr_t
and back with no change in value. (see See INT36-EX2.). The C Standard guarantees that a pointer to void
may be converted to or from a pointer to any object type and back again and that the result must compare equal to the original pointer. Consequently, converting directly from a char *
pointer to a uintptr_t
, as in this compliant solution, is allowed on implementations that support the uintptr_t
type.
...