TAL Programmer's Guide Data Alignment Addendum
Table Of Contents

TAL Misalignment Examples
TAL Programmer's Guide Data Alignment Addendum—524967-003
4-2
Invalid Conversion of Odd-Byte String Addresses
Invalid Conversion of Odd-Byte String
Addresses
Examples of invalid conversion of odd-byte string addresses to integer pointers, real
pointers, or structure pointers:
1. Assigning a string pointer or an integer expression to an integer pointer or a
structure pointer
The TAL compiler’s type checking is very weak: the compiler rejects assignments
only when the assigned value's size is the wrong number of 16-bit registers. Mixing
extended addresses and 32-bit data does not cause compilation errors. At run
time, however, these pointer conversions work correctly only when the converted
value has an even-byte address.
Odd-byte addresses can result from pointer arithmetic and from assigning an odd-
valued integer expression to a pointer. See Example 4-2
on page 4-4 and
Example 4-3
on page 4-5.
Example 4-1. TAL Null Pointer Check
Change this:
DEFINE NULL = -1d#;
struct listnode (*); begin
int status;
...
int(32) next;
end;
int .ext listhead (listnode);
int .ext node (listnode);
@node := @listhead;
while node.status = okay !used too soon! and @node <> NULL do begin
...
@node := node.next;
end;
To this:
DEFINE NULL = -1d#;
struct listnode (*); begin
int status;
...
int(32) next;
end;
int .ext listhead (listnode);
int .ext node (listnode);
@node := @listhead;
while @node <> NULL and node.status = okay do begin
...
@node := node.next;
end;