BUG: Signed 4-byte Integer Overlow Not Caught by the CompilerLast reviewed: March 28, 1996Article ID: Q149132 |
The information in this article applies to:
SYMPTOMSThe compiler does not catch or reports incorrect information for signed four-byte integers that are one value greater than the allowable range for these numerical types. For signed four-byte integers, the allowable range is -2147483648 to 2147483647.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONIn the following sample code, the compiler does not catch and report the literal value of 2147483648 as an overflow error. When the compiler catches the out of range literal value of -2147483649, it incorrectly reports it as positive.
Sample CodeC Compile options needed: none
INTEGER*4 MYLONG MYLONG = 2147483647 ! OK MYLONG = 2147483648 ! out of range - not caught MYLONG = 2147483647+1 ! out of range - caught MYLONG = -2147483648 ! OK MYLONG = -2147483649 ! out of range - caught reported positive MYLONG = -2147483648-1 ! out of range - caught WRITE(*,*) MYLONG END |
Additional reference words: 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |