The compiler is able to catch the situation where a subscript for a table reference is hard-coded as zero. For example:
000037 DISPLAY "W-VALEUR-O2(0 J) = <" W-VALEUR-O2(0 J) '>'
results in this compiler error:
37 IGYPS2017-E "0" was found as a subscript. A value of 1 was assumed.
The compiler is not able to catch the situation where a derived/calculated subscript for a table reference is zero. For example:
000005 WORKING-STORAGE SECTION.
000011 01 TABLEAU.
000012 02 TAB1 OCCURS 5.
000013 03 EL-TAB1.
000014 04 EL-TAB1-CHAR PIC X(2).
000015 04 EL-TAB1-NUM PIC 9(3).
000016 03 EL-TAB2 OCCURS 5.
000017 05 W-VALEUR-01 PIC 999.
000018 05 W-VALEUR-02 PIC 999.
000019 PROCEDURE DIVISION.
000020 MOVE 0 TO J
000021 DISPLAY "W-VALEUR-01(2 0) = <" W-VALEUR-01(2 J) '>'
000022 DISPLAY "W-VALEUR-02(2 0) = <" W-VALEUR-02(2 J) '>'
000023 GOBACK.
results in no error produced by the compiler.
SSRANGE is designed to check the resulting address of the table reference, not the value of the subscript itself.
SSRANGE is able to catch the situation when the resulting address referred to by a subscript falls outside the boundary of the table. For example:
000006 WORKING-STORAGE SECTION.
000007 01 MYLIST.
000008 03 ARR1 OCCURS 10 TIMES.
000009 04 ARR2 OCCURS 10 TIMES.
000010 05 ARR-D1 PIC X(10).
000011 01 IDX PIC 9(9) VALUE 0.
000012
000013 PROCEDURE DIVISION.
000014 MOVE 'HELLO' TO ARR-D1(IDX 6)
000015 DISPLAY 'ARR-D1(IDX 6) = <' ARR-D1(IDX 6) '>'
000016 GOBACK.
IGZ0304W The reference to table ARR1 by verb number 1 on line 14 in program TABLE3 addressed an area outside the
region of the table.
IGZ0304W The reference to table ARR1 by verb number 1 on line 15 in program TABLE3 addressed an area outside the
region of the table.
ARR-D1(IDX 6) = <HELLO >
SSSRANGE is not able to catch the situation when the resulting address referred to by a subscript falls inside the boundary of the table, but the subscript value itself is zero. For example:
000006 WORKING-STORAGE SECTION.
000007 01 MYLIST.
000008 03 ARR1 OCCURS 10 TIMES.
000009 04 ARR2 OCCURS 10 TIMES.
000010 05 ARR-D1 PIC X(10).
000011 01 IDX PIC 9(9) VALUE 0.
000012
000013 PROCEDURE DIVISION.
000014 MOVE 'HELLO' TO ARR-D1(6 IDX)
000015 DISPLAY 'ARR-D1(6 IDX) = <' ARR-D1(6 IDX) '>'
000016 GOBACK.
ARR-D1(6 IDX) = <HELLO >
This request is to add a new compiler option, SSCHECK, which will check the actual value of each subscript when it is used in a table reference to see if it is zero. If it is zero, either a warning message or abend will occur, depending upon whether the MSG or ABD suboption of SSCHECK.
In theory, this SSCHECK could also be expanded to include a ZERO/ALL suboption.
ZERO: Flag a subscript only if it is set to zero.
ALL: Flag a subscript if it is zero or less than the lower boundary in the OCCURS clause or greater than the upper boundary in the OCCURS clause for the table it is referencing.
SSCHECK(ALL,ABD) would produce an abend in this case, even though SSRANGE would not.
000006 WORKING-STORAGE SECTION.
000007 01 MYLIST.
000008 03 ARR1 OCCURS 10 TIMES.
000009 04 ARR2 OCCURS 10 TIMES.
000010 05 ARR-D1 PIC X(10).
000011 01 IDX PIC 9(9) VALUE 11. <= Greater than 10
000012
000013 PROCEDURE DIVISION.
000014 MOVE 'HELLO' TO ARR-D1(6 IDX)
000015 DISPLAY 'ARR-D1(6 IDX) = <' ARR-D1(6 IDX) '>'
000016 GOBACK.
Hi, this Idea is being accepted. but in a different context. The intention is to update SSRANGE (without an new suboption) to automatically check subscripts to make sure they are within the bounds of the OCCURS clause.
This idea will be updated further once we put it into plan.
This idea will be investigated further and will be updated once a decision has been made.