pTAL Guidelines for TAL Programmers
Differences Between TAL and pTAL
pTAL Guidelines for TAL Programmers—527256-002
3-22
OVERFLOW_TRAPS Directive
NOOVERFLOW_TRAPS
disables overflow traps for procedures and BEGIN-END blocks that do not specify
an attribute to enable overflow traps. This is the default for the EpTAL compiler.
POPOVERFLOW_TRAPS
pops the top item from the compile-time stack of OVERFLOW_TRAPS values and
sets the current value of OVERFLOW_TRAPS to the value popped off the stack.
PUSHOVERFLOW_TRAPS
pushes onto a compile-time stack the value of the OVERFLOW_TRAPS directive
at the current point of compilation without changing its value.
For an explanation of directive stacks, see the pTAL Reference Manual.
In pTAL, you can use the OVERFLOW_TRAPS directive to enable or disable traps.
The OVERFLOW_TRAPS directive specifies the default value of a pTAL program’s
overflow trapping behavior when you run it as a native process.
In TAL, you can use the OVERFLOW_TRAPS directive, but it does not ensure the
trapping characteristics of your program. In TAL, the directive does not affect directly
the object code generated by the compiler except at the end of a BEGIN-END block.
See ENABLE_OVERFLOW_TRAPS Block Attribute on page 3-24 for more details.
The OVERFLOW_TRAPS directive specifies a program’s default overflow trapping
behavior. If you specify OVERFLOW_TRAPS and do not specify any other trapping
specifications—described later in this subsection—an arithmetic overflow (including
divide by zero) causes a trap to the currently active trap handler. If your program has
not specified a trap handler, it traps to the operating system, which aborts your
program.
If you specify NOOVERFLOW_TRAPS, an arithmetic overflow does not cause a trap.
You can test for overflow using the $OVERFLOW routine. (See Section 2, Coding
Guidelines, for more information about using $OVERFLOW.)
You can specify an OVERFLOW_TRAPS directive only where a procedure declaration
can begin. You cannot specify an OVERFLOW_TRAPS directive at the beginning of a
subprocedure.
You can push the current value of the OVERFLOW_TRAPS directive onto a compile-
time stack, which can hold up to 32 OVERFLOW_TRAPS directive values.
The OVERFLOW_TRAPS directive is recognized by D20 and later TAL compilers but
affects the object code generated by the compiler only to the extent described earlier in
this section.
You can also use the OVERFLOW_TRAPS and NOOVERFLOW_TRAPS procedure
attributes and the ENABLE_OVERFLOW_TRAPS and
DISABLE_OVERFLOW_TRAPS block attribute to control overflow traps. These
attributes are described in subsections that follow.