Microsoft KB Archive/70280

= BUG: Nested Loops and FAR Arrays Produce Incorrect Results =

Article ID: 70280

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q70280



SYMPTOMS
Compiling a program that uses nested loops and FAR arrays causes one of the following run-time problems:
 * 1) Incorrect results -or-


 * 1) Protection violation -or-


 * 1) Run-time error R6001 - null pointer assignment -or-


 * 1) 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-


 * 1) 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: KB70280

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.