Menu

error: invalid expression

GnuCOBOL
pottmi
2023-05-09
2023-05-15
  • pottmi

    pottmi - 2023-05-09

    I have this code:

      01  PARMLIST                            USAGE  IS  POINTER.
           05  CICS-PNTR.
           05  LOAD-BLLS.
               10  MY-LIST-PNTR.
    
          IF  TGRAC-GRAC-PNTR  NOT =  NULLS
    

    The NOT = NULLS line fails with:

    error: invalid expression

    Is there some option I can turn on that will allow a POINTER to be
    compared with NULL?

    This compiles on Mainframe and Micro Focus.

     
  • Ralph Linkletter

    IF TGRAC-GRAC-PNTR NOT = NULLS
    TGRAC-GRAC-PNTR is not defined in your example code.
    Given the example would not the group-level LOAD-BLLS also be assigned a POINTER definition ?
    Seems like a strange data structure.
    My own practice, I would not assign a definition (pointer, comp-3, comp, etc) to a group level.
    Ralph

     
    • Arnold Trembley

      Arnold Trembley - 2023-05-09

      IBM COBOL supports usage at the group level, which applies to all elementary items in the group.

      https://www.ibm.com/docs/en/cobol-zos/6.3?topic=entry-usage-clause

      "The USAGE clause can be specified for a data description entry with any level-number other than 66 or 88.

      "When specified at the group level, the USAGE clause applies to each elementary item in the group. The usage of elementary items must not contradict the usage of a group to which the elementary items belongs."

       
      • pottmi

        pottmi - 2023-05-09

        Here is the strange thing....

        I use that variable in many other places in the code and it compiles
        just fine. Only the "IF TGRAC-GRAC-PNTR NOT = NULLS" is throwing
        that error.

        This is a couple million lines of code so changing the code is not my
        first choice.

        On Tue, May 9, 2023 at 2:01 AM Arnold Trembley
        arn79@users.sourceforge.net wrote:

        IBM COBOL supports usage at the group level, which applies to all elementary items in the group.

        https://www.ibm.com/docs/en/cobol-zos/6.3?topic=entry-usage-clause

        "The USAGE clause can be specified for a data description entry with any level-number other than 66 or 88.

        "When specified at the group level, the USAGE clause applies to each elementary item in the group. The usage of elementary items must not contradict the usage of a group to which the elementary items belongs."


        error: invalid expression


        Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gnucobol/discussion/cobol/

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

         
        • pottmi

          pottmi - 2023-05-14

          COBOL Crew,

          Any suggestions on this error?

          Is this something that should be "fixed" in GnuCOBOL or is it just
          obtuse code that should be changed?

          Can anyone recommend a change that would work?

          Also, is there an option that instructs cobc to output the offending
          line of code?

          On Tue, May 9, 2023 at 10:28 AM pottmi pottmi@users.sourceforge.net wrote:

          Here is the strange thing....

          I use that variable in many other places in the code and it compiles
          just fine. Only the "IF TGRAC-GRAC-PNTR NOT = NULLS" is throwing
          that error.

          This is a couple million lines of code so changing the code is not my
          first choice.

          On Tue, May 9, 2023 at 2:01 AM Arnold Trembley
          arn79@users.sourceforge.net wrote:

          IBM COBOL supports usage at the group level, which applies to all elementary items in the group.

          https://www.ibm.com/docs/en/cobol-zos/6.3?topic=entry-usage-clause

          "The USAGE clause can be specified for a data description entry with any level-number other than 66 or 88.

          "When specified at the group level, the USAGE clause applies to each elementary item in the group. The usage of elementary items must not contradict the usage of a group to which the elementary items belongs."


          error: invalid expression


          Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gnucobol/discussion/cobol/

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


          error: invalid expression


          Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gnucobol/discussion/cobol/

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

           
          • Arnold Trembley

            Arnold Trembley - 2023-05-14

            Where is TGRAC-GRAC-PNTR defined, and how is it defined in COBOL?

            Could it possibly be in a copybook somewhere, or could it possibly be a special register in a non-GnuCOBOL compiler? Is it possible that TGRAC-GRAC-PNTR is misspelled or not defined in the compile unit?

            I don't see any reason for that statement to fail, based on this test program named testpntr.cbl which I ran in Windows MinGW32 GnuCOBOL 3.1.2:

               IDENTIFICATION DIVISION.
               PROGRAM-ID. testpntr. 
               ENVIRONMENT DIVISION.
               DATA DIVISION.
               WORKING-STORAGE SECTION.
               01  WS-BELL-CHAR                PIC X(01)   VALUE X'07'.  
               01  TGRAC-GRAC-PNTR             USAGE IS POINTER.         
               PROCEDURE DIVISION.
                   DISPLAY "Hello, World! " WS-BELL-CHAR 
              ***  CALL "C$SLEEP" USING 001                   
                   continue after 0.500 seconds               
                   DISPLAY "One more time " WS-BELL-CHAR 
                   MOVE NULLS                  TO TGRAC-GRAC-PNTR 
                   DISPLAY TGRAC-GRAC-PNTR 
                   IF TGRAC-GRAC-PNTR NOT = NULLS 
                       DISPLAY "TGRAC-GRAC-PNTR IS NOT NULLS" 
                   ELSE 
                       DISPLAY "TGRAC-GRAC-PNTR IS EQUAL TO NULLS!" 
                   END-IF 
                   STOP RUN.
            

            And the results were:

            GnuCOBOL Compile Returncode = 0
            1 file(s) copied.
            1 file(s) copied.

            Microsoft Windows [Version 10.0.19045.2965] Sun 05/14/2023 1:04:48
            C:\COBOL>testpntr
            Hello, World!
            One more time
            0x00000000
            TGRAC-GRAC-PNTR IS EQUAL TO NULLS!

            I also tested it under 64bit MSYS2 GnuCOBOL 3.2-rc2 for Windows and the results were only different in the width of the displayed pointer:

            cobc -x -Wall -fnotrunc -t C:\Users\Arnold\AppData\Local\Temp\testpntr.lst -o C:\Users\Arnold\AppData\Local\Temp\testpntr.exe testpntr.cbl

            GnuCOBOL Compile Returncode = 0
            1 file(s) copied.
            1 file(s) copied.

            Microsoft Windows [Version 10.0.19045.2965] Sun 05/14/2023 1:09:16
            C:\COBOL>testpntr
            Hello, World!
            One more time
            0x0000000000000000
            TGRAC-GRAC-PNTR IS EQUAL TO NULLS!

            Microsoft Windows [Version 10.0.19045.2965] Sun 05/14/2023 1:09:21
            C:\COBOL>

             

            Last edit: Arnold Trembley 2023-05-14
            • Arnold Trembley

              Arnold Trembley - 2023-05-14

              I tried a variation of testpntr.cbl where the pointer is defined as follows:

                 01  MY-POINTERS             USAGE IS POINTER.   
                     05  TGRAC-GRAC-PNTR.
              

              And this compile FAILED with "invalid expression" when the pointer is compared to NULLS.

              I also tried with VALUE NULLS and with PIC X(08) VALUE NULLS (which I know would work on IBM COBOL for MVS). The only additional information was to report an error for a Picture clause on a pointer, which also was allowed in IBM COBOL.

              So it would appear that you have found a GnuCOBOL bug where USAGE POINTER does not work at the group level. I know it does work in IBM mainframe COBOL.

              But if you specify USAGE POINTER at the elementary level in your data definition, it should work.

              Kind regards,

               

              Last edit: Arnold Trembley 2023-05-14
              • Arnold Trembley

                Arnold Trembley - 2023-05-15

                Pottmi has created an official BUG report for this problem, and I have added a comment because it is broken in GC 3.1.2 and GC 3.2 rc2.

                https://sourceforge.net/p/gnucobol/bugs/883/

                 
          • Vincent (Bryan) Coen

            The use of a group level usage clause is valid at 01  etc.

            So if your code looks like this it is correct and the compiler is
            showing a bug :

            01   A   USAGE POINTER.
                  03   B.
                  03   C.

            Remind us, what is the version and platform of the Cobol compiler ?

            You should report this problem as a bug but specify the compiler version
            it is found in.

            On 14/05/2023 02:27, pottmi wrote:

            COBOL Crew,

            Any suggestions on this error?

            Is this something that should be "fixed" in GnuCOBOL or is it just
            obtuse code that should be changed?

            Can anyone recommend a change that would work?

            Also, is there an option that instructs cobc to output the offending
            line of code?

            On Tue, May 9, 2023 at 10:28 AM pottmi pottmi@users.sourceforge.net wrote:

            Here is the strange thing....
            
            I use that variable in many other places in the code and it compiles
            just fine. Only the "IF TGRAC-GRAC-PNTR NOT = NULLS" is throwing
            that error.
            
            This is a couple million lines of code so changing the code is not my
            first choice.
            
            On Tue, May 9, 2023 at 2:01AM Arnold Trembley
            arn79@users.sourceforge.net wrote:
            
            IBM COBOL supports usage at the group level, which applies to all
            elementary items in the group.
            
            https://www.ibm.com/docs/en/cobol-zos/6.3?topic=entry-usage-clause
            
            "The USAGE clause can be specified for a data description entry
            with any level-number other than 66 or 88.
            
            "When specified at the group level, the USAGE clause applies to
            each elementary item in the group. The usage of elementary items
            must not contradict the usage of a group to which the elementary
            items belongs."
            
             

Log in to post a comment.