SIZE ERROR, Truncation, and what the ANSI/ISO Standard says 
Author Message
 SIZE ERROR, Truncation, and what the ANSI/ISO Standard says

Given another "ongoing" thread, I thought that I would quote EXACTLY what
the ANSI/ISO Standard currently says about the fact that TRUNCATION is *not*
a part of arithmetic operations when no ON SIZE ERROR phrase is specified
(or when it is specified - for that matter).  The following is from Page
B-36 of the "Corrections Amendment"

"(8) Size error condition without ON SIZE ERROR phrase (1 NUC). If a size
error condition occurs and an ON SIZE ERROR phrase has not been specified,
the program will continue and the value of any affected resultant identifier
is undefined.

This substantive change was introduced by third Standard COBOL; however, it
was not identified as a substantive change until amendment 2. Therefore, it
has been listed here and as item 45 in paragraph 2.2, Substantive Changes
Potentially Affecting Existing Programs (Third Standard COBOL).

Justification:
In second Standard COBOL, the rules for transfer of control were not
explicit when a size error condition occurred and an ON SIZE ERROR phrase
was not specified. The rules for this situation have been made explicit in
third Standard COBOL to ensure that execution will continue using the
standard rules for transfer of control. For example:

  01 DIGIT1 PIC 9 VALUE 9.
  01 DIGIT2 PIC 99 VALUE 9.
  01 VALUE-ZERO PIC 9 VALUE 0.
  PROCEDURE DIVISION.
    STATEMENT-1.
        ADD +1 TO DIGIT1 DIGIT2.
   STATEMENT-X.
        DIVIDE VALUE-ZERO INTO DIGIT1 DIGIT2.

In second Standard COBOL, most implementations allowed the program to
continue execution after performing the statement in paragraph STATEMENT-1.
However, some implementations terminated execution during execution of the
statement in paragraph STATEMENT-2. In third Standard COBOL, the rules have
been clarified to insure that the program will continue execution after both
of these statements. Furthermore, the rules now explicitly state that the
value in DIGIT2 will be defined as 10 after executing STATEMENT-1. On the
other hand the value of DIGIT1 after the execution of STATEMENT-1 and both
DIGIT1 and DIGIT2 after the execution of STATEMENT-2 will be undefined."

--
Bill Klein
 wmklein <at> ix.netcom.com



Sat, 19 Jul 2003 23:48:55 GMT  
 SIZE ERROR, Truncation, and what the ANSI/ISO Standard says
Bill, isn't what happens, tho' (from what I've seen) is that (at least when
adding)
you get   1.  (the actual result of the operation).

I think 'undefined' means - the standard does not define the result and the
compiler write is free to do what it wants (just like closing a File with
data in the
01 - some Vendors on other systems leave the rec alone, IBM ensures it is
unusable.

Of course, when EVER the possibility of underflow/overflow (AKA
Truncation/Size error)
a careful COBOL coder, uses the ON SIZE ERROR.



Quote:
> Given another "ongoing" thread, I thought that I would quote EXACTLY what
> the ANSI/ISO Standard currently says about the fact that TRUNCATION is
*not*
> a part of arithmetic operations when no ON SIZE ERROR phrase is specified
> (or when it is specified - for that matter).  The following is from Page
> B-36 of the "Corrections Amendment"

> "(8) Size error condition without ON SIZE ERROR phrase (1 NUC). If a size
> error condition occurs and an ON SIZE ERROR phrase has not been specified,
> the program will continue and the value of any affected resultant
identifier
> is undefined.

> This substantive change was introduced by third Standard COBOL; however,
it
> was not identified as a substantive change until amendment 2. Therefore,
it
> has been listed here and as item 45 in paragraph 2.2, Substantive Changes
> Potentially Affecting Existing Programs (Third Standard COBOL).

> Justification:
> In second Standard COBOL, the rules for transfer of control were not
> explicit when a size error condition occurred and an ON SIZE ERROR phrase
> was not specified. The rules for this situation have been made explicit in
> third Standard COBOL to ensure that execution will continue using the
> standard rules for transfer of control. For example:

>   01 DIGIT1 PIC 9 VALUE 9.
>   01 DIGIT2 PIC 99 VALUE 9.
>   01 VALUE-ZERO PIC 9 VALUE 0.
>   PROCEDURE DIVISION.
>     STATEMENT-1.
>         ADD +1 TO DIGIT1 DIGIT2.
>    STATEMENT-X.
>         DIVIDE VALUE-ZERO INTO DIGIT1 DIGIT2.

> In second Standard COBOL, most implementations allowed the program to
> continue execution after performing the statement in paragraph
STATEMENT-1.
> However, some implementations terminated execution during execution of the
> statement in paragraph STATEMENT-2. In third Standard COBOL, the rules
have
> been clarified to insure that the program will continue execution after
both
> of these statements. Furthermore, the rules now explicitly state that the
> value in DIGIT2 will be defined as 10 after executing STATEMENT-1. On the
> other hand the value of DIGIT1 after the execution of STATEMENT-1 and both
> DIGIT1 and DIGIT2 after the execution of STATEMENT-2 will be undefined."

> --
> Bill Klein
>  wmklein <at> ix.netcom.com



Tue, 22 Jul 2003 10:51:51 GMT  
 SIZE ERROR, Truncation, and what the ANSI/ISO Standard says
What you are talking about is "implementor defined" - which is a different
category (in ANSI-speak) than "undefined".

--
Bill Klein
 wmklein <at> ix.netcom.com

Quote:
> Bill, isn't what happens, tho' (from what I've seen) is that (at least
when
> adding)
> you get   1.  (the actual result of the operation).

> I think 'undefined' means - the standard does not define the result and
the
> compiler write is free to do what it wants (just like closing a File with
> data in the
> 01 - some Vendors on other systems leave the rec alone, IBM ensures it is
> unusable.

> Of course, when EVER the possibility of underflow/overflow (AKA
> Truncation/Size error)
> a careful COBOL coder, uses the ON SIZE ERROR.



> > Given another "ongoing" thread, I thought that I would quote EXACTLY
what
> > the ANSI/ISO Standard currently says about the fact that TRUNCATION is
> *not*
> > a part of arithmetic operations when no ON SIZE ERROR phrase is
specified
> > (or when it is specified - for that matter).  The following is from Page
> > B-36 of the "Corrections Amendment"

> > "(8) Size error condition without ON SIZE ERROR phrase (1 NUC). If a
size
> > error condition occurs and an ON SIZE ERROR phrase has not been
specified,
> > the program will continue and the value of any affected resultant
> identifier
> > is undefined.

> > This substantive change was introduced by third Standard COBOL; however,
> it
> > was not identified as a substantive change until amendment 2. Therefore,
> it
> > has been listed here and as item 45 in paragraph 2.2, Substantive
Changes
> > Potentially Affecting Existing Programs (Third Standard COBOL).

> > Justification:
> > In second Standard COBOL, the rules for transfer of control were not
> > explicit when a size error condition occurred and an ON SIZE ERROR
phrase
> > was not specified. The rules for this situation have been made explicit
in
> > third Standard COBOL to ensure that execution will continue using the
> > standard rules for transfer of control. For example:

> >   01 DIGIT1 PIC 9 VALUE 9.
> >   01 DIGIT2 PIC 99 VALUE 9.
> >   01 VALUE-ZERO PIC 9 VALUE 0.
> >   PROCEDURE DIVISION.
> >     STATEMENT-1.
> >         ADD +1 TO DIGIT1 DIGIT2.
> >    STATEMENT-X.
> >         DIVIDE VALUE-ZERO INTO DIGIT1 DIGIT2.

> > In second Standard COBOL, most implementations allowed the program to
> > continue execution after performing the statement in paragraph
> STATEMENT-1.
> > However, some implementations terminated execution during execution of
the
> > statement in paragraph STATEMENT-2. In third Standard COBOL, the rules
> have
> > been clarified to insure that the program will continue execution after
> both
> > of these statements. Furthermore, the rules now explicitly state that
the
> > value in DIGIT2 will be defined as 10 after executing STATEMENT-1. On
the
> > other hand the value of DIGIT1 after the execution of STATEMENT-1 and
both
> > DIGIT1 and DIGIT2 after the execution of STATEMENT-2 will be undefined."

> > --
> > Bill Klein
> >  wmklein <at> ix.netcom.com



Tue, 22 Jul 2003 21:40:27 GMT  
 SIZE ERROR, Truncation, and what the ANSI/ISO Standard says
Keeping in mind that the COBOL standard is the definition of
a programming language, "undefined" means the standard
imposes no requirement on the implementor to do anything
more to conform to the standard. This is not the same as,
"the compiler write is free to do what it wants".

In fact, the rules for what constitutes a conforming
implementation may actually prevent an implementor from
adding rules (to their conforming compiler) where the standard
uses the word "undefined."
------------------
Rick Smith


[...]

Quote:
>I think 'undefined' means - the standard does not define the result and the
>compiler write is free to do what it wants [...]



[...]
>> "(8) Size error condition without ON SIZE ERROR phrase (1 NUC). If a size
>> error condition occurs and an ON SIZE ERROR phrase has not been
specified,
>> the program will continue and the value of any affected resultant
>identifier
>> is undefined.

[...]


Wed, 23 Jul 2003 02:24:31 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Static scoping in BCPL (was Re: Are nested functions legal in ANSI/ISO Standard C)

2. Who cares about the ANSI/ISO Standard?

3. Reporting defects in the ANSI/ISO COBOL Standards

4. ABSOLUTELY last chance to comment on next COBOL ANSI/ISO Standard

5. ISO COBOL Standard available from ANSI online store

6. ANSI, ISO, IEEE STANDARD .. FORTRAN FAQ's

7. standards: ANSI LISP vs. ISO/IEC ISLISP

8. ANSI and ISO COBOL news

9. Fujitsu - asking for business case for ANSI/ISO conformance

10. ISO/IEC/NCITS/ANSI dinosaur. Was many threads

11. (ANSI/ISO) COBOL CD 1.10 Available

12. ANSI COBOL and ISO COBOL meetings this summer

 

 
Powered by phpBB® Forum Software