Next:Hints, Previous:Floating Point, Up:C Implementation-Defined Behavior [Contents][Index]
A cast from pointer to integer discards most-significant bits if thepointer representation is larger than the integer type,sign-extends5if the pointer representation is smaller than the integer type, otherwisethe bits are unchanged.
A cast from integer to pointer discards most-significant bits if thepointer representation is smaller than the integer type, extends accordingto the signedness of the integer type if the pointer representationis larger than the integer type, otherwise the bits are unchanged.
When casting from pointer to integer and back again, the resultingpointer must reference the same object as the original pointer, otherwisethe behavior is undefined. That is, one may not use integer arithmetic toavoid the undefined behavior of pointer arithmetic as proscribed inC99 and C11 6.5.6/8.
The value is as specified in the standard and the type is determinedby the ABI.
Future versions of GCC may zero-extend, or usea target-definedptr_extend pattern. Do not rely on sign extension.