PRB: LOGICAL Expression Passed to Subprogram Incorrectly
PSS ID Number: Q10822
Article last modified on 02-09-1993

3.30 3.31

MS-DOS


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

 - Microsoft FORTRAN for MS-DOS, versions 3.3, 3.31
----------------------------------------------------------------------

SYMPTOMS
   An application that passes a LOGICAL expression involving REAL
   numbers to a subprogram produces incorrect results.

CAUSE
   The compiler makes an incorrect assumption regarding the type of
   the expression.

RESOLUTION
   To work around this problem, perform one of the following two
   steps:

    - Modify the source code to declare the subprogram before the
      procedure call.

    - Modify the source code to assign the value of the LOGICAL
      expression that involves REAL numbers to a LOGICAL variable.
      Specify the variable as a parameter to the subprogram.

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

More Information:

The following code example demonstrates this problem. Specifically,
the program generates incorrect output (F) for the second WRITE
statement.

Sample Code
-----------

C Compile options needed: None

      LOGICAL TEST
      REAL    X

      X = 1.0
      TEST = (X .EQ. 1.0)
      CALL SUB1(TEST)
      CALL SUB1(X .EQ. 1.0)

      END

      SUBROUTINE SUB1(TEST)
      LOGICAL TEST

      WRITE(*, *) TEST
      RETURN
      END

Additional reference words: 3.30 3.31

=============================================================================

Copyright Microsoft Corporation 1993.
