gnucobol-users
[Top][All Lists]
Advanced

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

RE: [open-cobol-list] what happens in case of overflow?


From: Bill Klein
Subject: RE: [open-cobol-list] what happens in case of overflow?
Date: Mon Jan 30 14:35:03 2006

I think it is important (critical) to know that what happens when an
"overflow" condition occurs but there is no ON SIZE ERROR phrase specified,
is

   VERY unpredictable (and not portable)
        AND "undefined" in the ANSI Standard.

First, let's look at a "Substantive Change" entry in the '02 Standard
(pointing out a difference between the '85 and '02 Standards). From Page
815:

"15) Size error condition with no SIZE ERROR phrase. If a size error
condition occurs, the statement in which it occurs contains no SIZE ERROR or
NOT SIZE ERROR  phrase, and there is no associated declarative, the
implementor defines whether the run unit is terminated or execution
continues with incorrect values.

Justification:
In the previous COBOL standard, the rules for size error stated that
execution would continue with undefined values, but it was not clear where
execution would continue, particularly in conditional statements.
Additionally, continued execution with incorrect results was not acceptable
for many critical applications, where it might cause corruption of
databases, incorrect continued execution of the program, and potentially a
multitude of additional errors. It was prohibitive to modify programs to add
ON SIZE ERROR for every affected statement. Responding to user requirements,
several implementors terminated execution of the program in this situation;
in some cases, the implementor allowed selection of termination based on a
compiler directive.

The number and criticality of applications that terminated in this situation
provides strong justification for this change. It is expected that this
change will have little impact on existing programs because implementors are
free to continue or terminate, in accordance with their implementation of
the previous COBOL standard."

   ***

I know (for a fact) that IBM mainframes (for example) do NOT "abnormally
terminate" when an ON SIZE ERROR condition is "just" an overflow, but they
DO abnormally terminate for a "divide-by-zero" ON SIZE ERROR condition.

As the original note indicated, even when a run-time allows the program to
continue, the results of "receiving" fields differ from compiler to compiler
(and sometimes by compiler option or run-time settings).

It is worth "noting" that if you have something like:

01 Num-Fields.
   05  Send-Num1  Pic 9 Value 9.
   05  Recv-Num2  Pic 9 Value 0.
   05  Recv-Num3  Pic 99 Value 0.
                ...
Compute Recv-Num2 Recv-Num3 = Send-Num1 + 1

that RECV-Num3 *must* get a "correct" value of 10 after this statement. It
is only LRecv-Num2 that is "undefined" after the COMPUTE. 

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On 
> Behalf Of Jose Vilmar Estacio de Souza
> Sent: Thursday, January 26, 2006 11:00 AM
> To: address@hidden
> Subject: [open-cobol-list] what happens in case of overflow?
> 
> Hi all.
> I've the following program:
> 
> ------
>        identification division.
>        program-id. t4.
>        environment division.
>        data division.
>        working-storage section.
>        77 x pic 9(1) value 9.
>        procedure division.
>        display "x = " x
>        add 1 to x
>        display "x after the add = " x
>        stop run.
> ------
> 
> Executing the program I receive the following result:
> $ ./t4
> x = 9
> x after the add = 9
> $
> 
> When executing the same program in my old micro focus cobol 
> environment, I'm 
> receiving the following result:
> $ cobrun t4
> x = 9
> x after the add = 0
> $
> 
> Thanks. 
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep 
> through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  
> DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&;
> 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]