SSRANGE

Use SSRANGE to generate code that checks for out-of-range storage references.

SSRANGE option syntax

Read syntax diagramSkip visual syntax diagramNOSSRANGESSRANGE(,NOZLENZLENABDMSG)

Default is: NOSSRANGE

Start of changeSuboption default is: NOZLEN,ABD if only SSRANGE is specified.End of change

Abbreviations are: SSR|NOSSR

SSRANGE generates code that checks whether subscripts, including ALL subscripts, or indexes try to reference areas outside the region of their associated tables. Each subscript or index is not individually checked for validity. Instead, the effective address is checked to ensure that it does not reference outside the table.

Start of changeIf you specify SSRANGE with no suboptions, it will be accepted as a specification of SSRANGE(NOZLEN,ABD).End of change

Note: If the SSRANGE option is in effect, range checks are generated by the compiler and the checks are always conducted at run time. You cannot disable the compiled-in range checks at run time by specifying the runtime option CHECK(OFF).

Variable-length items are also checked to ensure that references are within their maximum defined length.

Reference modification expressions are checked to ensure that:

  • The starting position is greater than or equal to 1.
  • The starting position is not greater than the current length of the subject data item.
  • The length value (if specified) is greater than or equal to 1.
  • The starting position and length value (if specified) do not reference an area beyond the end of the subject data item.
Start of changeThe ZLEN and NOZLEN suboptions control how the compiler checks reference modification lengths:
  • If ZLEN is in effect, the compiler will generate code to ensure that reference modification lengths are greater than or equal to zero. Zero-length reference modification specifications will not get an SSRANGE error at run time.
  • If NOZLEN is in effect, the compiler will generate code to ensure that reference modification lengths are greater than or equal to 1. Zero-length reference modification specifications will get an SSRANGE error at run time. This is compatible with how SSRANGE behaved in previous COBOL versions.
End of change
Start of changeThe MSG and ABD suboptions control the runtime behavior of the COBOL program when a range check fails.
  • If MSG is in effect and a range check fails, a runtime warning message will be issued. Start of changeAlso, the affected statements will still be executed. End of change The program will continue and might potentially identify other out-of-range conditions.
  • If ABD is in effect and a range check fails, the first out-of-range condition will result in a runtime error message and the program will ABEND. You can find the next potential out-of-range condition by fixing the first out-of-range condition and then recompiling and running the program again. To identify all other potential out-of-range conditions, you might need to repeat this process several times.
End of change

For unbounded groups or their subordinate items, checking is done only for reference modification expressions. Subscripted or indexed references to tables subordinate to an unbounded group are not checked.

related concepts  
Reference modifiers

related tasks  
Checking for valid ranges