FIX: FORTRAN 5.0 Loop Optimization, Subroutine, & Array Problem (59422)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN compiler for OS/2 5.0

This article was previously published under Q59422

SYMPTOMS

In FORTRAN version 5.0, the loop optimizer does not correctly optimize the subroutine MOVE in the code below, producing incorrect output.

RESOLUTION

Compiling with /Od or /Odt resolves the problem.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN version 5.0. This problem was corrected in FORTRAN version 5.1.

MORE INFORMATION

Sample Code

       integer*2 buf(20)
      do 10 i=1,10
10    buf(i) = 9

      call move(10,buf(11),buf)

      write(*,'(10(i8))') (buf(i),i=1,20)
      end

      Subroutine move(npts, y1, y2)
      integer*2 y1(*), y2(*)
      do 10 i=1,npts
        y2(i) = y1(i)
10    continue
      return
      end
				
The following is the correct output:
    0     0     0     0     0     0     0     0     0     0
    0     0     0     0     0     0     0     0     0     0
				
The following is the incorrect output:
    0     0     0     0 21325 21024 28277 21549 28009  8293
    0     0     0     0     0     0     0     0     0     0
				

Modification Type:MajorLast Reviewed:10/23/2003
Keywords:kbbug kbfix KB59422