pTAL Guidelines for TAL Programmers
Differences Between TAL and pTAL
pTAL Guidelines for TAL Programmers—527256-002
3-25
ENABLE_OVERFLOW_TRAPS Block Attribute
Considerations
When the operating system starts a program, it enables overflow traps for that
program.
For a pTAL program running as a native process, you can specify any combination of
directives, procedure attributes, or block-level attributes. Anywhere overflow traps are
enabled in your program, the pTAL compiler generates code to test for overflow if the
last operator evaluated—the root operator—in the expression of an assignment
statement or in the conditional expression of an IF statement is one of the following:
•
Negate (unary -), +, -, *, /, '/'
•
$DBL of an INT, FIXED(0), REAL, or REAL(64) value
•
$DBLR of an INT, FIXED(0), REAL, or REAL(64) value
•
$FIX of a REAL or REAL(64) value
•
$FIXD
•
$FIXI
•
$FIXL
•
$FIXR of a REAL or REAL(64) value
•
$INT of a FIXED(0), REAL, or REAL(64) value
•
$INTR of a FIXED(0), REAL, or REAL(64) value
•
$SCALE for scale factors <= 4
For a pTAL program compiled with a D20 or later TAL compiler, only block-level
attributes cause changes to the trapping behavior of your program. If you want the
same behavior for both TNS and native processes, use block-level trapping attributes.
The overflow trapping state of code compiled with the pTAL compiler is always based
on the attributes and directives in effect at that point of the compilation. Procedures do
not inherit the trapping state of their callers.
The overflow trapping state of code compiled with a D20 or later TAL compiler is
always based on the block-level trap attributes. A called procedure always inherits the
trapping state of its caller. You can specify the trapping state of a called procedure by
specifying a block-level attribute on the BEGIN-END block that encloses the body of
the procedure; for example:
PROC p;
BEGIN: ENABLE_OVERFLOW_TRAPS
...
END;
You can ensure the trapping state of an entire program that you compile with a D20 or
later TAL compiler by specifying block-level attributes on the BEGIN-END block of your
‘main’ procedure; for example:
PROC my_main MAIN;
BEGIN: DISABLE_OVERFLOW_TRAPS
...
END;