#287 INITIALIZE statement with an ref-mod item containing FILLER doesn't work

2.0
closed
initialize (2)
4
2016-10-08
2013-12-17
No

See discussion at [e70481a4]. Snippet:

Standard INITIALIZE never changes filler items

Quoted from ANSI INCITS 23-1985:

Index data items and elementary FILLER data items are not affected by
the execution of an INITIALIZE statement.

Where 2002 adds the [WITH] FILLER phrase

the following data items are excluded as receiving-operands [and are therefore unchanged]:
[...] If the FILLER phrase is not specified, elementary data items with an explicit or implicit FILLER clause

Nonetheless it should always initialize if the item es ref-modded, see Edwards comment.

Simon

Related

Discussion: e70481a4
Discussion: How to add a bug report (and test program) and/or a wish-list item?

Discussion

  • Edward Hart

    Edward Hart - 2016-07-29

    I've scanned manual for 13 compilers and none of them documented this behaviour. Furthermore, this ticket has been untouched for two years.

     
  • Edward Hart

    Edward Hart - 2016-07-29
    • status: pending --> closed
    • Priority: 1 --> 1 - highest
     
  • Simon Sobisch

    Simon Sobisch - 2016-07-29
    • Priority: 1 - highest --> 7
     
  • Simon Sobisch

    Simon Sobisch - 2016-07-29

    Hm, either Jonathan is wrong (which I don't think) or "the mainframe" does INITIALIZE something (refmod:size) always as WITH FILLER (depending on the reference modification). Slightly a different issue but may be worth investigating (asking on the discussion forum) and recreate a feature request.
    A valid feature request would be to raise a warning if the INITIALIZE is targeted at a filler item (as it is done for MOVE CORR without any corr items).

     
  • Edward Hart

    Edward Hart - 2016-07-29

    I completely missed the discussion link, so I missed the "reference modification" bit. i was thinking about initialisation of group items.

    Jonathan was correct, GnuCOBOL's behaviour is a bug. To borrow IBM's paraphrasing of the standard (emphasis mine):

    Reference modification creates a unique data item that is a subset of data-name-1 or
    a subset of the value referenced by function-name-1 and its arguments, if any. This
    unique data item is considered an elementary data item
    without the JUSTIFIED
    clause.
    ...
    When data-name-1 is reference-modified, the unique data item has the same class,
    category, and usage as that defined for the data item
    referenced by data-name-1...

    Hence, the reference modification in [e70481a4] results in an alphanumeric item which should be initialised with spaces.

     

    Related

    Discussion: e70481a4

  • Edward Hart

    Edward Hart - 2016-07-29
    • status: closed --> open
     
  • Simon Sobisch

    Simon Sobisch - 2016-07-29
    • status: open --> accepted
    • Group: unclassified --> GC 2.0
    • Priority: 7 --> 4
     
  • Simon Sobisch

    Simon Sobisch - 2016-07-29

    Does this mean that all compilers should behave this way - or is it an MVS/IBM feature only?

     
    • Edward Hart

      Edward Hart - 2016-07-29

      All compilers should behave this way. I've tried Fujitsu COBOL85 now and that behaves like IBM. We'll have to add a configuration option for MF and ACUCOBOL.

      EDIT: Would you mind checking ACUCOBOL's behaviour again? According to their docs, a reference-modified data item is treated as an alphanumeric field, so using such an item in INITIALIZE should fill it with spaces.

       
      Last edit: Edward Hart 2016-07-29
      • Simon Sobisch

        Simon Sobisch - 2016-07-29

        Yes, I have to recheck ACUCOBOL and I think MF works correctly, too (I've just checked the docs for INITIALIZE back than).

         
      • Simon Sobisch

        Simon Sobisch - 2016-07-30

        Ignore the conf entry - even if someone does this I'd consider it as a bug and we can add the configuration entry later if we really need it.

        @Ed: Can you please try to fix this? Thank you.

         
  • Simon Sobisch

    Simon Sobisch - 2016-07-30
    • summary: INITIALIZE statement: Add a conf entry for implicit set of [WITH] FILLER --> INITIALIZE statement with an ref-mod item containing FILLER doesn't work
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -12,8 +12,6 @@
         the following data items are excluded as receiving-operands [and are therefore unchanged]:
         [...] If the FILLER phrase is not specified, elementary data items with an explicit or implicit FILLER clause
    
    -Therefore GNU Cobol is standard-conforming (and seem to work as MicroFocus and ACU-COBOL ever did, current ILE COBOL and Enterprise COBOL for z/OS docs state the same).
    -
    -If there are other vendors initializing all fillers by default we may should come up with a conf entry.
    +Nonetheless it should always initialize if the item es ref-modded, see Edwards comment.
    
     Simon
    
    • assigned_to: Edward Hart
     
  • Simon Sobisch

    Simon Sobisch - 2016-07-30

    Ticket moved from /p/open-cobol/feature-requests/25/

     
  • Edward Hart

    Edward Hart - 2016-08-04
    • labels: --> initialize
    • status: accepted --> closed
     
  • Edward Hart

    Edward Hart - 2016-08-04

    Fixed in [r1041].

     

    Related

    Commit: [r1041]

    • Simon Sobisch

      Simon Sobisch - 2016-08-05

      Thank you. And indeed ref-mod of PIC 9 is allowed (as long as it is USAGE DISPLAY, not sure if we check this already).

      Seems the following parts are not tested yet, please recheck and include if missing.

             01  MY-FILLER.
                 03  FILLER       PIC 9(6) VALUE 12345.
      
                 INITIALIZE MY-FILLER
                 IF MY-FILLER NOT = "012345"
                    DISPLAY "MY-FILLER (INIT): " MY-FILLER
                    END-DISPLAY
                 END-IF
      
                 INITIALIZE MY-FILLER WITH FILLER
                 IF MY-FILLER NOT = "000000"
                    DISPLAY "MY-FILLER (INIT FILLER): " MY-FILLER
                    END-DISPLAY
                 END-IF
      
                 INITIALIZE MY-FILLER ALL TO VALUE
                 IF MY-FILLER NOT = "012345"
                    DISPLAY "MY-FILLER (INIT TO VAL): " MY-FILLER
                    END-DISPLAY
                 END-IF
      
                 INITIALIZE MY-FILLER (2:3)
                 IF MY-FILLER NOT = "0   45"
                    DISPLAY "MY-FILLER (REF-MOD): " MY-FILLER
                    END-DISPLAY
                 END-IF       
      
       
      • Edward Hart

        Edward Hart - 2016-08-05

        All that works fine. I've added it to the testsuite in [r1042].

         

        Related

        Commit: [r1042]


        Last edit: Edward Hart 2016-08-05
        • Simon Sobisch

          Simon Sobisch - 2016-08-05

          Thank you. I've thought about adding the tests to make sure this will work in the future, too :-)

           

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks