bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [open-cobol-list] Bug Report and Bug Fix


From: Robert Sherry
Subject: RE: [open-cobol-list] Bug Report and Bug Fix
Date: Sat Apr 1 15:02:01 2006

John,

        Thanks for the response. I am wondering why it is working for you
and not for me. What version of the Open Source COBOL Compiler are you
using?

Bob Sherry 

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of John R.
Culleton
Sent: Saturday, April 01, 2006 1:24 PM
To: address@hidden
Cc: Robert Sherry
Subject: Re: [open-cobol-list] Bug Report and Bug Fix

On Saturday 01 April 2006 09:31, Robert Sherry wrote:
>             With the March release of the Open Source COBOL Compiler, the
> following program does not produce the expected output:
>
>
>
>        ID DIVISION.
>
>        PROGRAM-ID.      ADD1.
>
>        ENVIRONMENT      DIVISION.
>
>        CONFIGURATION SECTION.
>
>        INPUT-OUTPUT SECTION.
>
>        FILE-CONTROL.
>
>        DATA DIVISION.
>
>        FILE SECTION.
>
>        WORKING-STORAGE SECTION.
>
>
>
>         01 C1 PIC 9(4) USAGE IS COMP-5.
>
>        PROCEDURE DIVISION.
>
>         MOVE 100 TO C1.
>
>         DISPLAY C1
>
>         SUBTRACT 10 FROM C1.
>
>         DISPLAY C1
>
>         SUBTRACT 9 FROM C1.
>
>         DISPLAY C1
>
>         GOBACK.
>
>
Well, I have some suggestions. First instead of ID DIVISION,
which is an IBM variation, I would spell out IDENTIFICATION
DIVISION. Second DISPLAY usage is called that for a reason. I
don't remember what COMP-5 represents (In my day we had COMP and
COMP-3 as the usual choices) but it is obviously not DISPLAY. And
it is not in the recent standards. 

Just as a matter of safe practice I would move the number to a
USAGE DISPLAY field before displaying it instead of depending on
some automatic conversion. 

Finally I learned decades ago that if you want to do arithmetic
on a field make it a signed field.

But using open cobol 32 the following program performs
flawlessly:

000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. EXAM.
000180 DATA DIVISION.
000200 FILE SECTION.
000220 WORKING-STORAGE SECTION.
       77   C1 PICTURE 9(4) COMP-5.
       77   CDISP PICTURE 9(4).   
000230
000240 PROCEDURE DIVISION.
000250 001-MAIN-PROCEDURE.
         MOVE 100 TO C1.
         MOVE C1 TO CDISP.
         DISPLAY CDISP.
         SUBTRACT 10 FROM C1.
         MOVE C1 TO CDISP.
         DISPLAY CDISP.
         SUBTRACT 9 FROM C1.
         MOVE C1 TO CDISP.
         DISPLAY CDISP.
         DISPLAY C1.
         GOBACK.
------------------------------------
Here is the result:
0100
0090
0081
+0081

Then I tried it in Tiny COBOL.

Tiny COBOL didn't like the GOBACK in a standalone program
(neither do I) but by substituting STOP RUN it compiled and ran
OK. The only difference between OPEN COBOL and TINY was that the
display of C1 was shown signed in OPEN and unsigned in TINY.
Since the field itself was unsigned I say advantage TINY. 

If the above doesn't work in a more recent version of OPEN COBOL 
then you have indeed uncovered a bug.
 
John Culleton





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list




reply via email to

[Prev in Thread] Current Thread [Next in Thread]