Previous Table of Contents "New C Standard" commentary
A pointer to
A pointer to any incomplete or object type may be converted to a
745 the result shall compare equal to the original pointer.
746 For any qualifier q, a pointer to a non-q-qualified type may be converted to a pointer to the q-qualified version of the type;
747 the values stored in the original and converted pointers shall compare equal.
An integer constant expression with the value 0, or such an
expression cast to type
749 If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.
750 Conversion of a null pointer to another pointer type yields a null pointer of that type.
751 Any two null pointers shall compare equal.
752 An integer may be converted to any pointer type.
753 Except as previously specified, the result is implementation-defined, might not be correctly aligned, might not point to an entity of the referenced type, and might be a trap representation.56)
754 Any pointer type may be converted to an integer type.
755 Except as previously specified, the result is implementation-defined.
756 If the result cannot be represented in the integer type, the behavior is undefined.
757 The result need not be in the range of values of any integer type.
758 A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type.
759 If the resulting pointer is not correctly aligned57) for the pointed-to type, the behavior is undefined.
760 Otherwise, when converted back again, the result shall compare equal to the original pointer.
761 When a pointer to an object is converted to a pointer to a character type, the result points to the lowest addressed byte of the object.
55) The macro
763 56) The mapping functions for converting a pointer to an integer or an integer to a pointer are intended to be consistent with the addressing structure of the execution environment.
764 57) In general, the concept correctly aligned is transitive: if a pointer to type A is correctly aligned for a pointer to type B, which in turn is correctly aligned for a pointer to type C, then a pointer to type A is correctly aligned for a pointer to type C.
765 Successive increments of the result, up to the size of the object, yield pointers to the remaining bytes of the object.
766 A pointer to a function of one type may be converted to a pointer to a function of another type and back again;
767 the result shall compare equal to the original pointer.
768 If a converted pointer is used to call a function whose type is not compatible with the pointed-to type, the behavior is undefined.
769 Forward references: cast operators (6.5.4), equality operators (6.5.9), integer types capable of holding object pointers (126.96.36.199), simple assignment (188.8.131.52).
Created at: 2008-01-30 02:39:41
The text from WG14/N1256 is copyright © ISO
Created at: 2008-01-30 02:39:41 The text from WG14/N1256 is copyright © ISO