Menu ▾ ▴

#314 SEARCH ALL bug: ODO 0 TO ... doesn't immediately perform AT END if the depening is zero --> is broken with runtime checks activated

2.2
closed
2
2017-04-10
2016-09-08
No

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 (;;)
     ...

Related

Bugs: #313

Discussion

  • Simon Sobisch

    Simon Sobisch - 2016-11-06
    • status: accepted --> closed
    • assigned_to: Simon Sobisch
     
  • Simon Sobisch

    Simon Sobisch - 2016-11-06

    Fixed with [r1217].

     

Log in to post a comment.