FIX: Incorrect Range Checking with Arrays Dimensioned (1) (106560)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 4.0
  • Microsoft FORTRAN Compiler for MS-DOS 4.1
  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN Compiler for MS-DOS 5.1
  • Microsoft FORTRAN compiler for OS/2 4.1
  • Microsoft FORTRAN compiler for OS/2 5.0
  • Microsoft FORTRAN compiler for OS/2 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS 1.0
  • Microsoft Fortran Powerstation 32 for Windows NT 1.0

This article was previously published under Q106560

SYMPTOMS

Extended error handling (enabled by $DEBUG or /4Yb) does not catch subscript out-of-range errors for positive subscripts with arrays declared to have dimension (1).

STATUS

Microsoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.1, 5.0, and 5.1, and FORTRAN PowerStation version 1.0 for MS-DOS and Windows NT. This problem has been resolved with FORTRAN PowerStation maintenance release version 1.0a for MS-DOS.

FORTRAN PowerStation version 1.0 can be differentiated from the maintenance release version 1.0a by invoking the linker. Typing link32 | more from \F32\BIN directory will show version 2.8 for FORTRAN PowerStation version 1.0, and it will show version 1.0f for the maintenance release version 1.0a.

MORE INFORMATION

The lower range is correctly checked for dimension (1). Attempts to access array element 0 (zero) or less will generate a subscript range check error. Subscript range checking works correctly if the dimension is (1:1) or (N) where N is at least 2.

Sample Code

C Compile options needed: /4Yb

      integer a(1), b(1:1), c(2), i,n
      real    d(1)
      read *, i, n
      if     ( i .eq. 1 ) then
         a(n) = 3
         print *, a(n)
      elseif ( i .eq. 2 ) then
         b(n) = 3
         print *, b(n)
      elseif ( i .eq. 3 ) then
         c(n) = 3
         print *, c(n)
      elseif ( i .eq. 4 ) then
         d(n) = 3
         print *, d(n)
      end if
      end

C Input:    Result:
C  1 2         3
C  1 0         run-time error F6096: test.for(6)
C  2 2         run-time error F6096: test.for(9)
C  3 3         run-time error F6096: test.for(12)
C  4 2         3.000000
				

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kbfix KB106560