BUG: Signed 4-byte Integer Overlow Not Caught by the Compiler

Last reviewed: March 28, 1996
Article ID: Q149132
The information in this article applies to:
  • Microsoft Fortran PowerStation for Windows 95 and Windows NT, version 4.0

SYMPTOMS

The 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.

STATUS

Microsoft 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 INFORMATION

In 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 Code

C 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
KBCategory: kbprg kbbuglist
KBSubcategory: FORTLngIss



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: March 28, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.