Pointer Alignment
For the purposes of this section on pointer alignment, the term pointer refers to both pointer data items and procedure-pointer data items.
When a pointer is referenced, or is the subject of a REDEFINES clause, the object item must be in alignment. In other words, it must be located at an offset that is a multiple of 16 bytes from the beginning of the record.
A data item described as a pointer in the Working-Storage, Local-Storage or File sections is aligned. If the pointer is part of a structure that begins at level-number 01, the compiler aligns the beginning of the structure. After that, the compiler puts FILLER items in front of the pointer to make sure that it is also in alignment. The compiler issues a warning when it adds these FILLER items.
- If the process option NOLSPTRALIGN is in effect, the compiler does not add FILLER items to the structure. The compiler issues warnings regarding its assumption that you have aligned the 01-level items.
- If the process option LSPTRALIGN is in effect, the data item described as pointer is also aligned.
If a pointer is the subject of a REDEFINES clause in the Linkage section, and the object of the clause is not a pointer, you will receive a warning that you need to maintain pointer alignment. For the same situation in the Working-Storage, Local-Storage or File sections, an error will result if you do not align the object of the clause.
You can specify the SYNCHRONIZED clause along with USAGE IS POINTER or USAGE IS PROCEDURE-POINTER clause, but this clause is already implicit for pointers.
If the pointer is part of a table, the first item in the table is aligned, and to make sure that all occurrences of the pointer are also aligned, a filler item might be added to the end of the table.
To avoid adding FILLER items to data structures, place pointers at the beginning of the structures.