Menu ▾ ▴

#411 (RE)WRITE FILE should not be possible from report or sort-merge file description entry / figurative constant / numeric literals

GC 3.0
closed
None
5 - default
2018-07-18
2017-08-14
No
::cobolfree
REWRITE FILE file-name-1 [RECORD] FROM identifier-1 | literal-1

2002: REWRITE statement 14.8.33.2 / WRITE statement 14.8.47.2 Syntax rules:

10) / 7) If the FILE phrase is specified [...] literal-1 shall be an alphanumeric, boolean, or national literal and shall not be a figurative constant.
11) / 12) File-name-1 shall not reference a report file or a sort-merge file description entry.

Therefore the following should not compile:

::cobol
       IDENTIFICATION DIVISION.
       PROGRAM-ID. prog.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT f ASSIGN TO "asdfs"
               SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.
       FD  f.
       01  f-rec PIC 99B99B99.

       WORKING-STORAGE SECTION.
       01  num PIC 9(6) VALUE 123456.

       PROCEDURE DIVISION.
           OPEN OUTPUT f
           WRITE FILE f FROM zero
           WRITE FILE f FROM 0
           REWRITE FILE f FROM zero
           REWRITE FILE f FROM 0
           CLOSE f
           .
       END PROGRAM prog.

Discussion

  • Simon Sobisch

    Simon Sobisch - 2017-12-25

    Depending on the amount of changes the fix will either get in 3.0 final or 3.1.

     
  • Edward Hart

    Edward Hart - 2018-07-18

    The example demonstrates a different bug: ASSIGN DISPLAY somehow suppresses the "OPEN/WRITE/etc. not allowd on SORT files" errors. I will open a separate ticket for this issue.

     
  • Edward Hart

    Edward Hart - 2018-07-18
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -17,12 +17,12 @@
            ENVIRONMENT DIVISION.
            INPUT-OUTPUT SECTION.
            FILE-CONTROL.
    
    -           SELECT f ASSIGN TO DISPLAY
    +           SELECT f ASSIGN TO "asdfs"
                    SEQUENTIAL.
    
            DATA DIVISION.
            FILE SECTION.
    
    -       SD  f.
    +       FD  f.
            01  f-rec PIC 99B99B99.
    
            WORKING-STORAGE SECTION.
    @@ -37,5 +37,4 @@
                CLOSE f
                .
            END PROGRAM prog.
    -
     ~~~
    
     
  • Edward Hart

    Edward Hart - 2018-07-18

    Another bug is that replacing FD by RD in the modified example causes a segfault. I will fix this now.

     

    Last edit: Edward Hart 2018-07-18
  • Edward Hart

    Edward Hart - 2018-07-18
    • status: accepted --> closed
     
  • Edward Hart

    Edward Hart - 2018-07-18

    Fixed in [r2630].

     

Log in to post a comment.