gcc: Arrays and pointers implementation
1
1 4.7 Arrays and Pointers
1 =======================
1
1 * 'The result of converting a pointer to an integer or vice versa
1 (C90 6.3.4, C99 and C11 6.3.2.3).'
1
1 A cast from pointer to integer discards most-significant bits if
1 the pointer representation is larger than the integer type,
1 sign-extends(1) if the pointer representation is smaller than the
1 integer type, otherwise the bits are unchanged.
1
1 A cast from integer to pointer discards most-significant bits if
1 the pointer representation is smaller than the integer type,
1 extends according to the signedness of the integer type if the
1 pointer representation is larger than the integer type, otherwise
1 the bits are unchanged.
1
1 When casting from pointer to integer and back again, the resulting
1 pointer must reference the same object as the original pointer,
1 otherwise the behavior is undefined. That is, one may not use
1 integer arithmetic to avoid the undefined behavior of pointer
1 arithmetic as proscribed in C99 and C11 6.5.6/8.
1
1 * 'The size of the result of subtracting two pointers to elements of
1 the same array (C90 6.3.6, C99 and C11 6.5.6).'
1
1 The value is as specified in the standard and the type is
1 determined by the ABI.
1
1 ---------- Footnotes ----------
1
1 (1) Future versions of GCC may zero-extend, or use a target-defined
1 'ptr_extend' pattern. Do not rely on sign extension.
1