FIX: F6099: Integer Overflow with $DEBUG & 32K INTEGER*2 Array

ID: Q70654


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.01, 4.1, 5.0
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0


SYMPTOMS

Programs compiled with FORTRAN versions 4.0, 4.01, 4.1, and 5.0 that have an INTEGER*2 array dimensioned at exactly 32768 and that also access the last element of this array with a variable as a subscript, can give the following error during run time:

F6099: INTEGER overflow
These programs must be compiled with /4Yb or the $DEBUG metacommand to generate the error. If debug information is removed from the program, the code will run correctly.


RESOLUTION

One possible solution is to increase the array size by one.


STATUS

Microsoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.01, 4.1, and 5.0. This problem has been corrected in FORTRAN version 5.1.


MORE INFORMATION

The following code reproduces the problem:


      integer*4 i
      integer*2 n (32768)
      i=32768
      n(i)=1                    ! line 5
      print*,n(32768)
      end 
An integer overflow error is correctly flagged on line 5 when this code is compiled with /4Yb or $DEBUG. This program is overlowing since the array index must be multiplied by 4 to obtain the offset for the variable, since the machine is byte addressable.

Increasing the dimension of the array by one also removes the integer overflow, as illustrated by the following program:

      integer*4 i
      integer*2 n (32769)
      n(32768)=1
      print*,n(32768)
      end 

Additional query words: 5.00

Keywords :
Version : :4.0,4.01,4.1,5.0
Platform :
Issue type :


Last Reviewed: November 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.