gnucobol-users
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] CVS Update 20061015


From: Sergey Kashyrin
Subject: Re: [open-cobol-list] CVS Update 20061015
Date: Tue, 17 Oct 2006 21:16:40 -0400

John,

Unfortunately Open COBOL still fails, indicating a compiler bug.


Apply the fastfix I've send to the group and it will work fine.
It is not the full fix yet because N is not checked at runtime even with 
"-debug" mode and that's not that easy to do.

Sergey

----- Original Message ----- From: "John R. Culleton" <address@hidden>
To: <address@hidden>
Cc: "Roger While" <address@hidden>; "Robert Sherry" <address@hidden>; 
<address@hidden>
Sent: Tuesday, October 17, 2006 4:43 PM
Subject: Re: [open-cobol-list] CVS Update 20061015


On Tuesday 17 October 2006 13:27, Roger While wrote:
And this is perfectly correct.
Your table is specifically defined to only allow a subscript of
4, 5 or 6.
Therefore a reference X(3) is invalid.
(A compile time check)

Not exactly. The field X can occur from four to six times. If it occurs four times then x(1), x(2), x(3) and x(4) are all valid subscripted references. The occurs clause simply tells how many occurences there are. The subscripts always start at 1 and are valid through the maximum size of the table, in this case four. If the standard says otherwise then the standard has been screwed up somehow or else misinterpreted in the creation of Open COBOL.

I quote from my most recent COBOL text:
"After a variable-length table is loaded and the number of elements determined then it can be accessed or searched just like a fixed length table." _Structured COBOL Programming_ Shelly, Cashman, Foreman, 2000
And an older text:

"Thus, DAILY-TOTAL will have either 28, 29, 30 or 31 items depending on an input field called DAYS-IN -MONTH...."
"Structured Programming, Fourth Edition", Stern & Stern 1985

A situation where you could only reference the last four days of the month would be absurd.
But the program fails in both Tiny COBOL and Open COBOL as written.

The problem is more simple. Small compilers tend to be one pass compilers. At the time of evaluating the number of occurences the value of N has not yet been defined. If we rearrange the statements the program compiles and executes using tiny COBOL. Of course since no value is ever assigned to x(3) the display statement yields a blank. Here is the rearranged code.
       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       DATA             DIVISION.
       WORKING-STORAGE  SECTION.
       01 N             PIC 9 VALUE 4.
       01 G.
           02 X           PIC X OCCURS 4 TO 6 TIMES DEPENDING ON N.
       PROCEDURE        DIVISION.
           DISPLAY X(3).
           STOP RUN.

Unfortunately Open COBOL still fails, indicating a compiler bug. If I add the statement MOVE "A" TO X(3). then the Tiny COBOL version compiles, executes, and displays the letter A. but the Open COBOL version has two subscript errors.


Here's what the standard says -

-----
The value of the data item referenced by data-name-1 represents
the current number of occurrences of the subject of the entry.
The subject of this entry has a variable number of occurrences.
The value of integer-2 represents the maximum number of occurrences
and the value of integer-1 represents the minimum number of occurrences.
This does not imply that the length of the subject of the entry is
variable, but that the number of occurrences is variable.
At the time the subject of entry is referenced or any data item subordinate
or superordinate to the subject of entry is referenced, the value of the
data item referenced by data-name-1 shall fall within the bounds from
integer-1 through integer-2.
If the value of the data item does not fall within the specified bounds,
the EC-BOUND-ODO exception condition is set to exist.
The content of a data item whose occurrence number
exceeds the value of the data item referenced by data-name-1 is undefined.
  -----

Roger

>    I down loaded and built the latest release of the Open Source COBOL
>Compiler. I would expect the following program to compile:
>
>
>However, I get a compile time error stating that the subscript for X is
>wrong.
>
>Bob Sherry
>
>-----Original Message-----
>From: address@hidden
>[mailto:address@hidden On Behalf Of Roger
>While
>Sent: Sunday, October 15, 2006 5:57 AM
>To: address@hidden
>Subject: [open-cobol-list] CVS Update 20061015
>
>CVS updated.
>Tarball (AKA Prerelease) at :
>http://ww.sim-basis.de/open-cobol-0.33.tar.gz
>
>Too many things changed to list here.
>See the ChangeLog files in the top-level
>and sub-directories (cobc, libcob, config, bin, tests)
>
>Roger
>
>
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job
>easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>open-cobol-list mailing list
>address@hidden
>https://lists.sourceforge.net/lists/listinfo/open-cobol-list

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list

--
John Culleton
Able Indexing and Typesetting
Precision typesetting (tm) at reasonable cost.
Satisfaction guaranteed. http://wexfordpress.com


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&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]