FIX: Implicit AUTOMATIC Corrupts Subroutine Return Value (68220)



The information in this article applies to:

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

This article was previously published under Q68220

SYMPTOMS

The program below should print out the value 9999 for 'j', after the call to subroutine X modifies it, but the original value of 5 is printed.

RESOLUTION

Removing the AUTOMATIC statement fixes the problem, as does compiling with /Od.

STATUS

Microsoft has confirmed this to be a bug in the products listed above. This problem was corrected in FORTRAN PowerStation, version 1.0.

MORE INFORMATION

The following sample demonstrates the problem.

Sample code

       automatic
      character*80 a, b

      b = ' '
      i = 10
      j = i - 5
      a = b(j:i)

      write(*,*) 'j before call =', j
      call X ( j )
      write(*,*) 'j after call  =', j

      end

      subroutine X ( k )
      k = 9999
      return
      end
				

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kbfix KB68220