BUG: Smallest Negative Integers Cause Error on Input

Last reviewed: July 13, 1995
Article ID: Q109877
The information in this article applies to:
  • Microsoft FORTRAN PowerStation 32 for NT, version 1.0

SYMPTOMS

An attempt to execute a program that reads in the smallest negative integer within the range of the variable type may cause the following run-time error to be generated:

   run-time error F6100
   INTEGER overflow on input

RESOLUTION

Because these smallest integers do not cause a problem when calculated internally, this problem can be addressed by changing the input data to the smallest allowable value for the integer size, and then subtracting one (1) after the value is read in.

STATUS

Microsoft has confirmed this to be a problem in Microsoft FORTRAN PowerStation 32 for NT, version 1.0. This is not a problem in Microsoft FORTRAN for MS-DOS, version 5.1. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The range of integers that can be read in correctly is:

   -127 to 127 for INTEGER*1
   -32,767 to 32,767 for INTEGER*2
   -2,147,483,647 to 2,147,483,647 for INTEGER*4

The problem occurs when trying to read in

   -128 for INTEGER*1
   -32,768 for INTEGER*2
   -2,147,483,648 for INTEGER*4

Sample Code

C Compile options needed: have no effect C The following code demonstrates the problem:

      integer*1 i
      integer*2 j
      integer*4 k
      open(1,file='test.dat')
      do n=3,5
        write(1,*) -2**((2**n-1)) !write -128, -32768, -2147483648
      end do

      rewind(1)
      read(1,*,iostat=ierr) i
      if(ierr.eq.6100) then
        print*, 'error reading integer*1 was: ',ierr
      end if

      read(1,*,iostat=ierr) j
      if(ierr.eq.6100) then
        print*, 'error reading integer*2 was: ',ierr
      end if

      read(1,*,iostat=ierr) k
      if(ierr.eq.6100) then
        print*, 'error reading integer*4 was: ',ierr
      end if
      pause
      end

REFERENCES

Microsoft FORTRAN PowerStation 32 "Programmer's Guide," page 48, "Integer Data Types."


Additional reference words: 1.00
KBCategory: kbtool 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: July 13, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.