FIX: Incorrect Range Checking with Arrays Dimensioned (1)

Last reviewed: September 16, 1997
Article ID: Q106560
1.00 MS-DOS kbtool kbfixlist kbbuglist fixlist1.00a

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.1, 5.0, and 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, and 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, version 1.0
  • Microsoft FORTRAN PowerStation32 for Windows NT,version 1.0

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


Additional reference words: 1.00 4.00 4.00a 4.10 5.00 5.10 buglist1.00
buglist4.00 buglist4.10 buglist5.00 buglist5.10
KBCategory: kbtool kbfixlist kbbuglist
KBSubcategory: FLIss
Solution Type : kbfix


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: September 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.