FIX: No Error When Out-of-Range Value Read Into INTEGER*1Last reviewed: September 11, 1997Article ID: Q67230 |
4.00 4.01 4.10 5.00 | 4.10 5.00
MS-DOS | OS/2kbtool kbbuglist kbfixlist The information in this article applies to:
SYMPTOMSWhen 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.
CAUSEThe 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.
STATUSMicrosoft 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 INFORMATIONWhen 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 inputThe 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 0Therefore, 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 RTEThis cycle repeats every 128 values.
Sample CodeC Compile options needed: None
INTEGER*1 I10 READ (*, *) I WRITE (*, *) I GOTO 10 END |
Additional reference words: 4.00 4.01 4.10 5.00 buglist4.00 buglist4.01
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |