B.21 Cast Operators (§3.3.4)

The Standard specifies that a pointer can be converted to an integral type, but the size of the integer required and the result are implementation-defined. A pointer occupies the same amount of storage as objects of type int or long (or their unsigned equivalents). Therefore, a pointer can be converted to any of these integer types and back again without changing its value. No scaling takes place, and the representation of the value does not change.

Converting between a pointer and a shorter integer type, such as char , is similar to the conversion between an object of unsigned long type and a shorted integer type. The high-order bits of the pointer are discarded. Converting between a shorter integer and a pointer is similar to the conversion between the shorter integer type and unsigned long . The high- order bits of the pointer are filled with copies of the sign bit if the shorter integer type was signed. Messages are issued for cast operations of these types under the error-checking compiler option.


Previous Page | Next Page | Table of Contents | Index