Microsoft KB Archive/67230

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

Article ID: 67230

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.01
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0

-



This article was previously published under Q67230



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 query words: 4.00 4.01 4.10 5.00 buglist4.00 buglist4.01 buglist4.10 buglist5.00 fixlist5.10

Keywords: kbfix KB67230

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.