The should run into the AT END clause (or leave the search), but currently the WHEN is checked. Because of [bugs:#313] this always leads to an abort.
::cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. SEARCHBUG.
DATA DIVISION.
WORKING-STORAGE SECTION.
78 screen-max value 20.
77 screen-akt pic 9(02) comp-5.
*
01 screen-tab.
03 screen-entry occurs 0 to screen-max
depending on screen-akt
ascending key screen-name
indexed by screen-idx.
05 screen-name pic x(02).
05 screen-mode pic 9 value 0.
PROCEDURE DIVISION.
SEARCH ALL screen-entry
AT END
DISPLAY 'END'
*> we currently have cob_check_subscript here:
WHEN screen-name (screen-idx) = 'ABC'
DISPLAY 'FOUND'
END-SEARCH.
The error is the generated check in this part
::c
int head = 0 - 1;
int tail = (*(cob_u8_ptr) (b_7)) + 1;
for (;;)
{
if (head >= tail - 1)
{
/* Table end */
/* Line: 20 : DISPLAY : SEARCHBUG.cbl */
cob_set_location (st_1, 20, NULL, NULL, st_6);
cob_display (0, 1, 1, &c_1);
break;
}
...
The most performant way would likely to add a single check
::c
int head = 0 - 1;
int tail = (*(cob_u8_ptr) (b_7)) + 1;
if (*(cob_u8_ptr) (b_7) == 0) head = tail;
for (;;)
...
Fixed with [r1217].