[go: up one dir, main page]

Menu

#1008 Regression in move to numeric edited items

GC 3.x
closed
4
2024-12-17
2024-11-21
No

Hi,

It appears revision 5290 caused some regression in moves to numeric edited items.

Consider the following program:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. prog.

       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01 W-X1 PIC S9   VALUE 4.
       01 W-X2 PIC -B-  VALUE SPACES.

       01 W-Y1 PIC S9   VALUE -4.
       01 W-Y2 PIC +B+  VALUE SPACES.

       PROCEDURE DIVISION.
           MOVE W-X1 TO W-X2.
           DISPLAY W-X2.
           MOVE W-Y1 TO W-Y2.
           DISPLAY W-Y2.
           STOP RUN.

With 5290, it outputs:

 -4
 +4

While with any earlier revision, it outputs:

  4
- 4

I tried to have a look at the new optimized_move_display_to_edited function, but I believe the original author (@chaat) has a much better understanding of this code.

Related

Bugs: #1008
Commit: [r5555]

Discussion

  • Chuck Haatvedt

    Chuck Haatvedt - 2024-11-22

    David,

    This appears to be a bug in both the earlier revision as well as the current version.

    from IBM doc...

    https://www.ibm.com/docs/en/cobol-zos/6.3?topic=clause-floating-insertion-editing

    from 2022 ISO standard pg 449

    B    Each symbol 'B' represents a character position that will be checked to contain the character space if the symbol 'B' is neither part of floating insertion editing nor of zero suppression with replacement editing; otherwise, the character space or, if no significant numeric character appears to its left, the corresponding floating insertion character or replacement character respectively.
    

    here is the result with the Fujitsu COBOL compiler

    F:\AA-minGW32-static>prog-1008
      4
     -4
    

    with my fix...

    F:\AA-minGW32-static>cobcd -x prog-1008.cbl
    F:\AA-minGW32-static>prog-1008
      4
     -4
    

    ran my build from source with this patch and it passed all the testsuite and NIST tests successfully

    note that this test program should be added to the testsuite to ensure that going forward we check for regression on this.

        Chuck Haatvedt
    
     

    Last edit: Chuck Haatvedt 2024-11-22
  • David Declerck

    David Declerck - 2024-11-22

    Hi Chuck,

    Thank you for this patch ; that was quick ;)
    I'll check that it passes the CI on our GitHub mirror (P.S: it's open to anyone, feel free to use it to check your patches).
    Just to be more future-proof: can you think of any other "corner cases" of these moves to numeric edited that would be missing a test case ?
    Also, checking with @sf-mensch: is this patch OK for you ?

    • David
     

    Last edit: David Declerck 2024-11-22
    • Simon Sobisch

      Simon Sobisch - 2024-11-22

      So NIST is working fine with it?

      Am 22. November 2024 14:28:08 MEZ schrieb David Declerck ddeclerck@users.sourceforge.net:

      Hi Chuck,

      Thank you for this patch ; that was quick ;)
      I'll check that it passes the CI on our GitHub mirror.
      Also, checking with @sf-mensch: is this patch OK for you ?

      • David

      [bugs:#1008] Regression in move to numeric edited items

      Status: open
      Group: GC 3.x
      Created: Thu Nov 21, 2024 04:14 PM UTC by David Declerck
      Last Updated: Fri Nov 22, 2024 07:44 AM UTC
      Owner: nobody

      Hi,

      It appears revision 5290 caused some regression in moves to numeric edited items.

      Consider the following program:
      ```
      IDENTIFICATION DIVISION.
      PROGRAM-ID. prog.

        DATA DIVISION.
        WORKING-STORAGE SECTION.
      
        01 W-X1 PIC S9   VALUE 4.
        01 W-X2 PIC -B-  VALUE SPACES.
      
        01 W-Y1 PIC S9   VALUE -4.
        01 W-Y2 PIC +B+  VALUE SPACES.
      
        PROCEDURE DIVISION.
            MOVE W-X1 TO W-X2.
            DISPLAY W-X2.
            MOVE W-Y1 TO W-Y2.
            DISPLAY W-Y2.
            STOP RUN.
      

      With 5290, it outputs:
      -4
      +4
      While with any earlier revision, it outputs:
      4
      - 4
      ```

      I tried to have a look at the new optimized_move_display_to_edited function, but I believe the original author (@chaat) has a much better understanding of this code.


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gnucobol/bugs/1008/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #1008

    • Chuck Haatvedt

      Chuck Haatvedt - 2024-11-22

      here is from the IBM documentation, I've not checked the 2022 draft standard...

      Any simple-insertion symbols (B 0 / ,) within or to the immediate right of the string of floating insertion symbols are considered part of the floating character-string. If the period (.) special-insertion symbol is included within the floating string, it is considered to be part of the character-string.

      the comma works, but I've not checked the other two, the zero and slash.

           Chuck Haatvedt
      
       
    • Chuck Haatvedt

      Chuck Haatvedt - 2024-11-22
              IDENTIFICATION DIVISION.
             PROGRAM-ID. prog.
      
             DATA DIVISION.
             WORKING-STORAGE SECTION.
      
             01 W-X1 PIC S9   VALUE 4.
             01 W-X2 PIC -B-  VALUE SPACES.
             01 W-Z2 PIC -//00BB,,-    VALUE SPACES.
      
             01 W-Y1 PIC S9   VALUE -4.
             01 W-Y2 PIC +B+  VALUE SPACES.
      
             PROCEDURE DIVISION.
                 MOVE W-X1 TO W-X2.
                 DISPLAY W-X2.
                 MOVE W-Y1 TO W-Y2.
                 DISPLAY W-Y2.
                 MOVE W-X1 TO W-Z2.
                 DISPLAY W-Z2.
                 STOP RUN.
      

      gnucobol with current patch...

      F:\AA-minGW32-static>prog-1008
        4
       -4
       //00    4
      

      with Fujitsu compiler

      F:\AA-minGW32-static>prog-1008
        4
       -4
               4
      

      So perhaps this is another existing bug....

            Chuck Haatvedt
      
       
      • Chuck Haatvedt

        Chuck Haatvedt - 2024-11-22

        here is the result with another patch...

        F:\AA-minGW32-static>COBCD -x PROG-1008.CBL
        
        F:\AA-minGW32-static>prog-1008
          4
         -4
                 4
        

        This now matches the output from the Fujitsu compiler.

        i've attached a new version of the patch file.

         

        Last edit: Chuck Haatvedt 2024-11-23
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-11-23

    also testsuite #532 needs to be fixed as it is incorrect

    #                             -*- compilation -*-
    532. run_fundamental.at:450: testing MOVE to edited item (4) ...
    ./run_fundamental.at:2122: $COMPILE -Wno-truncate prog.cob
    ./run_fundamental.at:2123: $COBCRUN_DIRECT ./prog
    --- /dev/null   2024-11-22 17:49:35.000000000 -0600
    +++ /home/spcwh2/x32/gnucobol-trunk/tests/testsuite.dir/at-groups/532/stdout    2024-11-22 17:49:35.102903300 -0600
    @@ -0,0 +1,2 @@
    +EX-13.02 EXPECTING ==>'    $//00//10  '  WHAT I GOT WAS ==>'      $00//10  '<==
    +------------------001 TESTS FAILED------------------
    532. run_fundamental.at:450: 532. MOVE to edited item (4) (run_fundamental.at:450): FAILED (run_fundamental.at:2123)
    

    the expected result should be

    WHAT I GOT WAS ==>'      $00//10  '
    

    here is the patch file for run_fundamental.at

     

    Last edit: Chuck Haatvedt 2024-11-23
  • David Declerck

    David Declerck - 2024-12-06

    Hi Chuck,

    Seems there's a bit more that has been broken with these patches.
    With 5285, BLANK WHEN ZERO no longer works in some cases.

           IDENTIFICATION DIVISION.
           PROGRAM-ID. prog.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
           01 W-X  PIC -ZZZBZZ9,99 BLANK WHEN ZERO.
           PROCEDURE DIVISION.
               MOVE 0 TO W-X.
               DISPLAY W-X.
               STOP RUN.
    

    This displays:

           0,00
    

    The check for zero in optimized_move_display_to_edited might be a bit too restrictive, since the source data may contain a sign (in the example above, the literal 0 ends up in a display field which contains 00000000+).

     
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-12-06

    David,

    here is a patch file for MOVE.C

    the issue was when checking for "BLANK WHEN ZERO" was that if the sending field is signed, then we need to scan for 1 less byte. Note that the intermediate field is always created as display numeric with the same number of digits and scale as the receiving picture field. Also if the receiving field is signed then the intermediate field will always be signed separate and sign trailing.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. prog.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  W-X  PIC -ZZZBZZ9,99 BLANK WHEN ZERO.
       01  W-Y  PIC  ZZZBZZ9,99 BLANK WHEN ZERO.
       01  W-Z  PIC +ZZZBZZ9,99 BLANK WHEN ZERO.
       01  J    PIC S9(8)  COMP-5.
       PROCEDURE DIVISION.
           MOVE 0 TO J.
           MOVE J TO W-X.
           DISPLAY ' ===>' W-X '<==='.
           MOVE 1234 TO J.
           MOVE J TO W-X.
           DISPLAY ' ===>' W-X '<==='.
           MOVE -1234 TO J.
           MOVE J TO W-X.
           DISPLAY ' ===>' W-X '<==='.
    
           MOVE -1234 TO W-X.
           DISPLAY ' ===>' W-X '<==='.
    
           DISPLAY ' '.
    
           MOVE 0 TO J.
           MOVE J TO W-Y.
           DISPLAY ' ===>' W-Y '<==='.
           MOVE 1234 TO J.
           MOVE J TO W-Y.
           DISPLAY ' ===>' W-Y '<==='.
           MOVE -1234 TO J.
           MOVE J TO W-Y.
           DISPLAY ' ===>' W-Y '<==='.
    
           MOVE -1234 TO W-Y.
           DISPLAY ' ===>' W-Y '<==='.
    
           DISPLAY ' '.
    
           MOVE 0 TO J.
           MOVE J TO W-Z.
           DISPLAY ' ===>' W-Z '<==='.
           MOVE 1234 TO J.
           MOVE J TO W-Z.
           DISPLAY ' ===>' W-Z '<==='.
           MOVE -1234 TO J.
           MOVE J TO W-Z.
           DISPLAY ' ===>' W-Z '<==='.
    
           MOVE -1234 TO W-Z.
           DISPLAY ' ===>' W-Z '<==='.
           STOP RUN.
    
    
    output...
    
    F:\AA-minGW32-static>cobcd -x prog.cbl
    F:\AA-minGW32-static>prog
     ===>           <===
     ===>      12,34<===
     ===>-     12,34<===
     ===>-     12,34<===
    
     ===>          <===
     ===>     12,34<===
     ===>     12,34<===
     ===>     12,34<===
    
     ===>           <===
     ===>+     12,34<===
     ===>-     12,34<===
     ===>-     12,34<===
    

    This looks good to me, however you should confirm that and add this to the existing test in the testsuite.

      Thanks,
    
     
    ❤️
    1

    Last edit: Chuck Haatvedt 2024-12-06
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-12-11

    David,

    are you working with Simon to implement the latest patch that I sent to resolve the "BLANK WHEN ZERO" issue with a signed field ?

        Chuck Haatvedt
    
     
  • Simon Sobisch

    Simon Sobisch - 2024-12-17
    • labels: --> BLANK WHEN ZERO, editing, libcob
    • status: open --> closed
    • assigned_to: David Declerck
     

Log in to post a comment.