Checking for valid ranges

Use the SSRANGE compiler option to check whether addresses fall within proper ranges.

SSRANGE causes the following addresses to be checked:

  • Subscripted or indexed data references: Is the effective address of the specified table element within the maximum boundary of the containing group? (This checking is not done for UNBOUNDED tables and groups.)
  • Variable-length data references (a reference to a data item that contains an OCCURS DEPENDING ON clause): Is the actual length greater than or equal to zero, and within the maximum defined length for the group data item? (This checking is not done for UNBOUNDED groups.)
  • Reference-modified data references: Are the offset and length positive? Is the sum of the offset and length within the maximum length for the data item?

If the SSRANGE option is in effect, checking is performed at run time if the COBOL statement that contains the indexed, subscripted, variable-length, or reference-modified data item is executed.

If an effective address is outside the range of the data item that contains the referenced data, an error message is generated and the program stops. The message identifies the table or identifier that was referenced and the line number where the error occurred. Additional information is provided depending on the type of reference that caused the error.

If all subscripts, indices, and reference modifiers in a given data reference are literals and they result in a reference outside the data item, the error is diagnosed at compile time regardless of the setting of the SSRANGE option.

Performance consideration: SSRANGE can somewhat degrade performance because of the extra overhead to check each subscripted or indexed item.

related references  
SSRANGE  
Performance-related compiler options