Alignment Issues on Alpha

The Alpha edition of Visual C++ aligns all data types on natural boundaries unless you use structure packing or use recast pointers to move data to an unaligned address. Natural boundaries are, for example, a longword on a longword boundary, and a quadword on a quadword boundary.

Though these systems can automatically fix alignment errors in software, application performance degradation as a result of unaligned data operations can be significant. This is why you need to avoid alignment errors when porting code to Alpha platforms.

By default, the alignment rules for Alpha platforms place data at an address that is a multiple of the size of the type. For example, a 2-byte data type (short) must be placed on an address that is a multiple of two. A 4-byte data type (long) must be placed on an address that is a multiple of four. This is often referred to as “natural” alignment. Note that nonprimitive data types align to the largest of their member’s native types.

Thus, a primitive data type of size 2n bytes must have an address with the n least-significant bits set to 0. These rules imply that the following types have the alignment shown:

Primitive data type Alignment
char byte
short WORD (2 bytes)
int (equivalent to long on Windows NT) DWORD (4 bytes)
long DWORD
_ _int64 QUADWORD (8 bytes)
float DWORD
double QUADWORD
Any pointer type DWORD
_ _ptr64 QUADWORD
Structures, unions, and arrays The largest native member’s alignment requirement, possibly modified by /Zp or #pragma pack.