BUG: Nested Loops and FAR Arrays Produce Incorrect Results

Last reviewed: July 11, 1995
Article ID: Q70280
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN for OS/2, versions 5.0 and 5.1

SYMPTOMS

Compiling a program that uses nested loops and FAR arrays causes one of the following run-time problems:

  1. Incorrect results

    -or-

  2. Protection violation

    -or-

  3. Run-time error R6001 - null pointer assignment

    -or-

  4. Run-time error F6207: WRITE(CON) - I edit descriptor expected for INTEGER

Note: A FAR array is defined as any array with a FAR attribute, any array greater than 32K compiled without the /Gt switch, or any array larger than the value set by the /Gt switch.

RESOLUTION

Possible solutions include

  1. Compile with /Od to turn loop optimization off (/Odct /Gs may also be used to retain some optimization)

    -or-

  2. Use the NEAR attribute on the array accessed within the inside loop.

STATUS

Microsoft has confirmed this to be a bug in the products listed above.

This is not an issue with FORTRAN PowerStation, since FAR is not a supported attribute.

MORE INFORMATION

The following sample can be used to demonstrate the problem.

Sample code

      PROGRAM NestedLoop
c
      INTEGER*4 Channel(10), IBuff[FAR](100)
      Count = 1
      DO 1 Loop1=1,10
        Channel(Loop1) = Loop1
        DO 2 Loop2=1,10
          IBuff(Count) = Loop1 + Loop2
          Count = Count + 1

   2    CONTINUE
   1  CONTINUE
c c line number 13 c
      END

During execution this program generates the R6001 error under MS-DOS or a protection violation under OS/2.

Substituting line 13 with the following statement will generate the F6207 error during execution under DOS or a protection violation under OS/2:

   WRITE(*,'(I8)') Channel(1)

Substituting line 13 with the following statement will generate incorrect results during execution under DOS or a protection violation under OS/2:

     WRITE(*,*) Channel, IBuff


Additional reference words: 5.00 5.10
KBCategory: kbtool kberrmsg kbprb kbbuglist
KBSubcategory: FLIss


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 11, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.