6.3.2.3 Pointers

Previous Table of Contents

739 A pointer to void may be converted to or from a pointer to any incomplete or object type.

740 A pointer to any incomplete or object type may be converted to a pointer to void and back again;

741 the result shall compare equal to the original pointer.

742 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;

743 the values stored in the original and converted pointers shall compare equal.

744 An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.55)

745 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.

746 Conversion of a null pointer to another pointer type yields a null pointer of that type.

747 Any two null pointers shall compare equal.

748 An integer may be converted to any pointer type.

749 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)

750 Any pointer type may be converted to an integer type.

751 Except as previously specified, the result is implementation-defined.

752 If the result cannot be represented in the integer type, the behavior is undefined.

753 The result need not be in the range of values of any integer type.

754 A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type.

755 If the resulting pointer is not correctly aligned57) for the pointed-to type, the behavior is undefined.

756 Otherwise, when converted back again, the result shall compare equal to the original pointer.

757 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.

758 55) The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see 7.17.

759 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.

760 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.

761 Successive increments of the result, up to the size of the object, yield pointers to the remaining bytes of the object.

762 A pointer to a function of one type may be converted to a pointer to a function of another type and back again;

763 the result shall compare equal to the original pointer.

764 If a converted pointer is used to call a function whose type is not compatible with the pointed-to type, the behavior is undefined.

765 Forward references: cast operators (6.5.4), equality operators (6.5.9), integer types capable of holding object pointers (7.18.1.4), simple assignment (6.5.16.1).

Next

Created at: 2005-06-29 02:18:56 The text from WG14/N1124 is copyright © ISO