FIX: INTEGER*1 Items Passed by Value Incorrectly (77690)



The information in this article applies to:

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

This article was previously published under Q77690

SYMPTOMS

If a FORTRAN program attempts to pass an INTEGER*1 item to a subprogram by value, incorrect results may be generated.

CAUSE

The call to the subprogram pushes two bytes on the stack for the one-byte variable, causing the stack to be misaligned and the variable to be incorrectly accessed in the called routine.

RESOLUTION

The only reliable way to avoid this problem is to pass INTEGER*1 variables by reference.

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 code can be used to reproduce the problem:

Sample code

      subroutine sub1 (i,n)
      integer*1 i[value],n[value]

      write(*,*) i,n
      i= 44
      n= 55
      end

      integer*1 i,n
      i = 4
      n = 5
      call sub1(i,n)
      write(*,*) i,n
      end
				

Modification Type:MajorLast Reviewed:10/23/2003
Keywords:KB77690