COBOL - Opções de compilação - NUMCHECK
The NUMCHECK compiler option tells the compiler whether to generate extra code to validate data items when they are used as sending data items. For zoned decimal (numeric USAGE DISPLAY) and packed decimal (COMP-3) data items, the compiler generates implicit numeric class tests for each sending field. For binary data items, the compiler generates SIZE ERROR checking to see whether the data item has more digits than its PICTURE clause allows.
The NUMCHECK option is updated to remove redundant checks for invalid data, thus improving runtime performance. There may be fewer runtime messages than before.
The analysis done to remove redundant checks is more involved at OPT(1|2) than at OPT(0). OPT(0) does a simpler form of the analysis to keep compilation time as low as possible. There may be fewer messages at higher OPT levels.
When the compiler is able to determine at compile time that a check will always find invalid data, a compile-time message is produced and the runtime check is removed. (See MSG|ABD below.)
Default is: NONUMCHECK
Suboption defaults are:
Abbreviations are: NONC | NC
The default is ZON(ALPHNUM) when ZON is specified with no suboptions.
Specifying ZON or ZON(ALPHNUM) causes the compiler to generate code for an implicit numeric class test for zoned decimal (numeric USAGE DISPLAY) data items that are used as sending data items in COBOL statements.
Specifying ZON(NOALPHNUM) causes the compiler to generate code for an implicit numeric class test for zoned decimal (numeric USAGE DISPLAY) data items that are used as sending data items in COBOL statements, except when they are used in a comparison with an alphanumeric data item, alphanumeric literal or alphanumeric figurative constant.
Receivers are not checked, unless they are both a sender and a receiver, such as data item B in the following sample statements:
ADD A TO B
DIVIDE A INTO B
COMPUTE B = A + B
INITIALIZE B REPLACING ALPHANUMERIC BY B
This checking is done before the data is used in each statement:
Specifying PAC causes the compiler to generate code for an implicit numeric class test for packed decimal (COMP-3) data items that are used as sending data items in COBOL statements. For packed decimal data items that have an even number of digits, the unused bits are checked for ones.
When the compiler is able to determine at compile time that a check will always find invalid data, a compile-time error-level message is produced and the check is removed regardless of whether MSG or ABD is in effect.
Performance considerations: NUMCHECK is much slower than NONUMCHECK, depending on how many zoned decimal (numeric USAGE DISPLAY) data items, packed decimal (COMP-3) data items, and binary data items are used in a COBOL program. Since COBOL V6.2 with service applied, performance of NUMCHECK has been improved. However, performance is still best when specifying NONUMCHECK, and will be better at a higher OPT level.
Note: ZONECHECK is deprecated but is tolerated for compatibility, and it is replaced by NUMCHECK(ZON(ALPHNUM)).