C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
HP C Implementation-Defined Behavior
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
A-29
G.5 Common Extensions
Alignment Issues
TNS C and C++ considers objects of integral types to exist only on word boundaries.
Consequently, it is invalid to use an odd-byte address to access such an object. On
TNS systems, if an integral type extended pointer contains an odd-byte address, the
system ignores the last bit of the address and accesses the object in the even address
one byte below. On TNS/R and TNS/E systems, the results of using an integral type
extended pointer containing an odd-byte address are undefined. The code might
continue executing or trap. Therefore, it is important for you to ensure that all extended
pointers contain addresses that are even except for pointers to char. Extended
pointers are those of type long int or those of type int with the 32-bit (wide) data
model in effect, in which case an int is represented by 32 bits.
TNS systems are word-aligned. In this example, the size of str differs depending on
whether this code is executed on a word-aligned or byte aligned machine. On a word
aligned machine str is allocated 6 bytes of storage. On a byte-aligned machine, str
is allocated 5 bytes of storage. On the TNS system, str is allocated 6 bytes of
storage.
Struct tag{
char c[3];
int x;
} str;