BUG: Nested Loops and FAR Arrays Produce Incorrect Results

ID: Q70280


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


SYMPTOMS

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

  1. Incorrect results


  2. -or-

  3. Protection violation


  4. -or-

  5. Run-time error R6001 - null pointer assignment


  6. -or-

  7. 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)


  2. -or-

  3. 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 query words: nofps 5.00 5.10

Keywords :
Version : :5.0,5.1
Platform :
Issue type :


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