TAL Programmer's Guide Data Alignment Addendum

TAL Programmer's Guide Data Alignment Addendum524967-003
4-1
4 TAL Misalignment Examples
In TNS mode and accelerated mode, the targets of nonstring pointers and nonstring
reference parameters must be aligned on 2-byte memory boundaries for correct
operation. TAL and other TNS compilers automatically guarantee this alignment for all
compiler-managed variables; however, certain source errors involving pointers can
create odd-byte misalignments that are not detected at compilation time. The results of
odd-byte extended addresses depend on the specific NonStop server and the system
configuration, but they might include erratic “rounding down” and abnormal program
termination.
In a TAL program, some coding errors that can cause misaligned addresses are:
Uninitialized and Other Invalid Pointers on page 4-1
Invalid Conversion of Odd-Byte String Addresses on page 4-2
Incorrect Layout on page 4-7
Uninitialized and Other Invalid Pointers
Examples of using uninitialized and other invalid pointers:
Using an optional call-by-reference parameter that was omitted
Using special odd values for null pointers (for example, -1d) and not checking for
the appropriate value of null everywhere necessary
Dereferencing pointer-valued fields of a structure when the structure pointer is null
When the structure pointer is null, the structures fields are random bits.
Dereferencing a pointer-valued member of a redefined (“equivalenced”) variable
(inside or outside of a structure) when that alternative is not active and initialized
See Example 4-1 on page 4-2, which checks for a null pointer after some, but not
all, pointer references, instead of before all pointer references.