COBOL Manual for TNS and TNS/R Programs

Procedure Division
HP COBOL Manual for TNS and TNS/R Programs522555-006
8-26
SIZE ERROR Phrase
Values Undefined When SIZE ERROR Phrase is Absent
When a size error condition occurs during execution of a statement for which the
SIZE ERROR phrase is not specified, a trap 2 (arithmetic overflow) occurs unless
a NOTRAP2 directive has suspended arithmetic overflow trapping. If a NOTRAP2
directive has suspended arithmetic overflow trapping, results are undefined.
Values Remain Untouched When SIZE ERROR Phrase is Present
When a size error condition occurs during execution of an arithmetic statement for
which the SIZE ERROR phrase is specified, the value of the affected receiving
data items is not altered. That is, these data items retain whatever values they held
before the size error condition arose. Unaffected data items receive new values as
expected. The program has no mechanism by which it can determine which data
items were the cause of the size error condition.
SIZE ERROR, NOT SIZE ERROR, and Transfer of Control
After completion of the execution of the arithmetic operations, if the size error
condition occurred, the imperative statement in the SIZE ERROR phrase is
executed. If execution of the imperative statement causes explicit transfer of
control (due to a procedure branching or conditional statement) control is
transferred according to the rules for that statement; otherwise, when the
imperative statement has been executed, control passes to the end of the
arithmetic statement and the NOT SIZE ERROR phrase (if any) is ignored.
When no size error condition occurs during the execution of an arithmetic
statement, the SIZE ERROR phrase (if any) is ignored, and control passes to the
NOT SIZE ERROR phrase (if one is present) or to the end of the arithmetic
statement. If execution of the imperative statement causes explicit transfer of
control (due to a procedure branching or conditional statement), control is
transferred according to the rules for that statement.
CORRESPONDING Phrase and the Size Error Condition
When the CORRESPONDING phrase appears in an ADD or SUBTRACT
statement and any of the individual operations produces a size error condition, the
imperative statement in the SIZE ERROR phrase is not executed until all the
individual additions or subtractions are completed.
Note. The NMCOBOL compiler, which has traps set by default, ignores the NOTRAP2
directive and issues a warning.
Use the NOTRAP2 directive only during the process of conversion from COBOL 74 to
HP COBOL. It is provided to enable programs that do not include SIZE ERROR phrases to
be compiled and executed in HP COBOL without investing programmer time in analyzing
the potential for overflow problems. The availability of this directive might be discontinued
in HP COBOL after a period of time.