PRB: Incorrect Results From Self-Referential Array Calculation
PSS ID Number: Q11835
Article last modified on 02-09-1993
PSS database name: H_Fortran

3.31

MS-DOS


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft FORTRAN for MS-DOS, version 3.31
----------------------------------------------------------------------

SYMPTOMS
   An application generates incorrect results when it assigns an
   element of an INTEGER array to a REAL array and then assigns the
   INTEGER array element a new value computed from an arithmetic
   expression that involves itself.

CAUSE
   The compiler generates incorrect code in this situation.

RESOLUTION
   To work around this problem, modify the source code to specify the
   $NOFLOATCALLS metacommand.

STATUS
   Microsoft confirmed this to be a problem in FORTRAN version 3.31
   for MS-DOS. The problem was corrected in FORTRAN version 4.0 for
   MS-DOS.

More Information:

The following code example demonstrates this problem. Specifically, it
produces the results 0, 0 instead of the desired result 0, 6.

Sample Code #1
---------------

C Compile options needed: None

      $STORAGE:2
      PROGRAM ASST
      REAL COORD(2)
      INTEGER ACC(2)
      INTEGER I
      I = 2
      COORD(I) = ACC(I)
      ACC(I) = ACC(I) + 6
      WRITE(*, *) ACC
      END

The following code example produces correct results.

Sample Code #2
--------------

C Compile options needed: None

      $STORAGE:2
      $NOFLOATCALLS
      PROGRAM ASST
      REAL COORD(2)
      INTEGER ACC(2)
      INTEGER I
      I = 2
      COORD(I) = ACC(I)
      ACC(I) = ACC(I) + 6
      WRITE(*, *) ACC
      END

Additional reference words: 3.31 TAR55281

Copyright Microsoft Corporation 1993.