FIX: No Error When Out-of-Range Value Read Into INTEGER*1

Last reviewed: September 11, 1997
Article ID: Q67230
4.00 4.01 4.10 5.00 | 4.10 5.00
MS-DOS              | OS/2
kbtool kbbuglist kbfixlist

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0

SYMPTOMS

When an application reads a value less than -128 or larger than 127 into an INTEGER*1 variable, no run-time error occurs. Compiling with the /4Yb compiler option switch or the $DEBUG metacommand does not change the observed results.

CAUSE

The run-time error management routine inspects the first byte of the input value to determine if it is in range and ignores the remaining bytes.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.01, 4.1, and 5.0 for MS-DOS and versions 4.1 and 5.0 for OS/2. This problem was corrected in FORTRAN version 5.1 for MS-DOS and OS/2.

MORE INFORMATION

When an application reads an integer smaller than -127 or larger than 128 into an INTEGER*1 variable, the run-time library is designed to produce the following error:

   run-time error F6100:  READ
   -INTEGER overflow on input

The observed behavior is as follows:

      127 =  01111111               Returns the value 127
      128 =  10000000               Returns run-time error
      255 =  00000000 11111111      Returns run-time error
      256 =  00000001 00000000      Returns the value 0

Therefore, if the first byte is out of range, the application correctly generates an error. However, if the first byte is in range, the program ignores the other bytes, produces no error, and returns the value of the first byte.

Entering the values into the code example below produces corresponding results, as follows:

    0-127     Returns proper value
    128-255   Causes a Run-Time Error (RTE) as expected
    256-383   Returns value minus 256 (should cause an RTE)
    384-511   Causes an RTE

This cycle repeats every 128 values.

Sample Code

C Compile options needed: None

      INTEGER*1 I
10 READ (*, *) I
      WRITE (*, *) I
      GOTO 10
      END


Additional reference words: 4.00 4.01 4.10 5.00 buglist4.00 buglist4.01
buglist4.10 buglist5.00 fixlist5.10
KBCategory: kbtool kbfixlist kbbuglist
KBSubcategory: FLIss
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.