Sun Studio 12: C++ User's Guide

A.2.53 –misalign

SPARC: Permits misaligned data, which would otherwise generate an error, in memory. This is shown in the following code:

char b[100];
int f(int * ar) {
return *(int *) (b +2) + *ar;

This option informs the compiler that some data in your program is not properly aligned. Thus, very conservative loads and stores must be used for any data that might be misaligned, that is, one byte at a time. Using this option may cause significant degradation in runtime performance. The amount of degradation is application dependent.

A.2.53.1 Interactions

When using #pragma pack on a SPARC platform to pack denser than the type’s default alignment, the -misalign option must be specified for both the compilation and the linking of the application.

Misaligned data is handled by a trap mechanism that is provided by ld at runtime. If an optimization flag (-xO{1|2|3|4|5} or an equivalent flag) is used with the -misalign option, the additional instructions required for alignment of misaligned data are inserted into the resulting object file and will not generate runtime misalignment traps.


If possible, do not link aligned and misaligned parts of the program.

If compilation and linking are performed in separate steps, the –misalign option must appear in both the compile and link commands.