Code Generation Conventions |
Pointers
to all data types are 4 bytes long and are aligned on a 4-byte (fullword)
boundary unless the
bytealign
compiler option or
__noalignmem
keyword is used. All pointers to data have the same representation.
(However, code that relies on this fact is likely to be nonportable.)
NULL
has all 32 bits set to 0.
The rest of this section is relevant only if you need
to know the details of pointer representation or if you plan to create pointers
in non-C code and pass them to C code.
IBM 370 and XA addressing do not use all 32 bits of
a 4-byte pointer. In 24-bit addressing mode, only bits 8 through 31 (starting
at the left) are used as an address. In 31-bit addressing mode (provided only
on XA machines), only bits 1 through 31 are used as an address (bit 0 is not).
All addresses generated by the compiler have the nonaddress bits (bits 0 through
7 or bit 0) set to 0. Therefore, all pointers that are set to an address by
C code (whether at compile time or execution time) have the nonaddress bits
set to 0.
In most circumstances, it does not matter whether the
nonaddress bits of a pointer are 0. The bits are ignored by the hardware when
the pointer is used to address data. However, if pointers are compared, the
setting of the bits becomes significant. If you create pointers in non-C code
and pass them to C code, be sure that the nonaddress bits are 0, or turn them
off (using a cast) in C code before using the pointer in comparison operations.
The value in the nonaddress bits also becomes significant
if pointers are subtracted from each other. In this case, the code generated
by the compiler always clears the nonaddress bits to 0 before doing the subtraction,
so this case need not concern you.
Finally, note that pointer assignment, pointer addition,
and pointer-integer subtraction do not set the nonaddress bits to 0. If these
operations take a pointer created outside of C as input and that pointer has
nonaddress bits set, then the result may also have nonaddress bits set (not
necessarily the same bits).
To summarize, the compiler always creates pointers with
the nonaddress bits all set to 0 but may propagate non-zero values in these
bits from pointers created outside of C.
Copyright © 2001
by SAS Institute Inc., Cary, NC, USA. All rights reserved.