The values of subscripts and index items are checked by this COBOL system, with an RTS error 153 ("Subscript out of range") given if they are found to be out of range. However, checking subscripts and index items decreases the performance of your application to some extent. To avoid this decrease in performance you can use the NOBOUND directive to disable such checking. If the NOBOUND directive is used and a subscript or index item is out of range when referencing a table, a protection violation might occur. If you get unexpected results or a protection violation error in an application that has been compiled or generated with the NOBOUND directive, you should recompile the program without the directive and rerun it to determine if the fault is caused by a subscript error.
The following programs show how you could experience unexpected results as a result of inadvertently using an out-of-range subscript when the NOBOUND directive is specified. Because of the value passed from Bound-main, Build-sub moves "1" to the 21st element of an array that is only 20 elements in size. Because the NOBOUND directive is specified, this COBOL system permits this operation, which overwrites the next data item, c. If the NOBOUND directive was not set, the COBOL system would have given RTS error 153 ("Subscript out of range") when the MOVE was performed.
program-id. "bound-main". working-storage section. 01 a pic 99. procedure division. move 21 to a call "bound-sub" using a stop run. end program "bound-main". $set align(2 fixed) nobound program-id. "bound-sub". working-storage section. 01 b pic x occurs 20. 01 c pic xx. linkage section. 01 a pic 99. procedure division using a. move (1) to b(a) exit program.