Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal bug, bad generation of MOVE UNSAFE instruction TO qualified name. #1191

Closed
mayanje opened this issue Nov 14, 2018 · 4 comments
Closed
Assignees
Labels

Comments

@mayanje
Copy link
Contributor

mayanje commented Nov 14, 2018

We have an internal private source code in which the following code is generated

      *       MOVE UNSAFE RECCTR-DPO-DAT-FIN-CTR-CAT
      *                                      TO OutputAccount::DueDate
              MOVE        RECCTR-DPO-DAT-FIN-CTR-CAT
                                             TO OutputAccount::DueDate
              MOVE        RECCTR-DPO-DAT-FIN-CTR-CAT
                                             TO DueDate OF OutputAccount

The fact is that the MOVE... instruction is generated twice one with the qualified named unchanged and the second with the qualified name translated.

@mayanje mayanje self-assigned this Nov 14, 2018
@mayanje mayanje changed the title Internal bug, baad generation of MOVE UNSAFE instruction TO qualified name. Internal bug, bad generation of MOVE UNSAFE instruction TO qualified name. Nov 14, 2018
@mayanje
Copy link
Contributor Author

mayanje commented Nov 14, 2018

This issue can be reproduced with the source code on TypeCobolTeam's privateshare, with the file
TypeCobol_Bugs\Issues\1191\MOVE_QUALIFIED_BUG2.tcbl
There is also a README.txt file for a TypeCobol command line in the same directory.

@mayanje
Copy link
Contributor Author

mayanje commented Nov 15, 2018

Ok I succeed to have a sample to reproduce this issue, the following code will generate the issue:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. Functions.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 RECCTR-DPO-DAT-FIN-CTR-CAT PIC 9.
       PROCEDURE DIVISION.
       DECLARE PROCEDURE InitFrom PRIVATE
           INPUT arg PIC 9.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 RECCTR-DPO-DAT-FIN-CTR-CAT PIC 9.
       01 RECCTR-DAT-ECH-FIN PIC 9.
       01 TypeOutputAccount TYPEDEF STRICT.
                05 DueDate PIC 9.
       01 OutputAccount TYPE TypeOutputAccount.
           PROCEDURE DIVISION.
           EVALUATE TRUE
           WHEN NOT ( RECCTR-DPO-DAT-FIN-CTR-CAT = 0 )
              MOVE UNSAFE RECCTR-DPO-DAT-FIN-CTR-CAT
                                             TO OutputAccount::DueDate
           WHEN NOT ( RECCTR-DAT-ECH-FIN = ZERO )
              MOVE UNSAFE RECCTR-DAT-ECH-FIN TO OutputAccount::DueDate
           WHEN OTHER
              MOVE SPACE               TO OutputAccount::DueDate
           END-EVALUATE
           .
       END-DECLARE.
       CALL InitFrom INPUT RECCTR-DPO-DAT-FIN-CTR-CAT.
       END PROGRAM Functions.

@mayanje
Copy link
Contributor Author

mayanje commented Nov 15, 2018

So the piece of generate code will looks like;

      *Functions.InitFrom - Params :
      *		input(arg: pic 9)
           EVALUATE TRUE
           WHEN NOT ( RECCTR-DPO-DAT-FIN-CTR-CAT = 0 )
      *       MOVE UNSAFE RECCTR-DPO-DAT-FIN-CTR-CAT
      *                                      TO OutputAccount::DueDate
              MOVE        RECCTR-DPO-DAT-FIN-CTR-CAT
                                             TO OutputAccount::DueDate
              MOVE        RECCTR-DPO-DAT-FIN-CTR-CAT
                                             TO DueDate OF OutputAccount
           WHEN NOT ( RECCTR-DAT-ECH-FIN = ZERO )
      *       MOVE UNSAFE RECCTR-DAT-ECH-FIN TO OutputAccount::DueDate
              MOVE        RECCTR-DAT-ECH-FIN TO DueDate OF OutputAccount
           WHEN OTHER
      *       MOVE SPACE               TO OutputAccount::DueDate
              MOVE SPACE               TO DueDate OF OutputAccount
           END-EVALUATE
           .
       END PROGRAM d1dd0726InitFrom.

@mayanje
Copy link
Contributor Author

mayanje commented Nov 15, 2018

The reason is that the Qualifier action comes before erasing UNSAFE word on the MOVE, both actions Qualifer and Erase use replacement tokens, but it is necessary for replacement tokens to be inserted sorted by the location in the target node. Here the replacement token to erase the UNSAFE word is added at the end rather than as first, thus the Codegen creates two buffer for non contigues locations. This occurs in very special cases. Thanks to who reported this issue.

@mayanje mayanje added this to the v1.3 Codegen refacto milestone Nov 15, 2018
smedilol pushed a commit that referenced this issue Nov 20, 2018
…or the Codegen.

This is important for Insert and Delete replacement tokens, like those of the Qualifier, Replace and Erase actions. Qualifier's tokens are already sorted as they appear first.
@maxime645 maxime645 mentioned this issue May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant