FIX: Complex Constant Folding Produces Incorrect Results

ID: Q78927


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.1
  • Microsoft FORTRAN for OS/2, version 5.1


SYMPTOMS

The compiler attempts to calculate simple arithmetic expressions involving complex constants at the time of compilation. It produces incorrect results.


RESOLUTION

Assign complex constants to variables and use the complex variables in all arithmetic expressions.


STATUS

Microsoft has confirmed this to be a problem 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


       complex a,b,c

      b = (3,4)

      a = (3,4)**2.
      b = b**2

      c=(3,4)**2

c The above expression produces incorrect results because the
c compiler "precalculates" the multiplication incorrectly. The
c expression that has a decimal point on the 2 is not seen as a
c multiplication so it is not calculated by the compiler.  The run-
c time correctly calculates complex expressions.

      print*, a
      print*, b
      print*, c  ! incorrect result
      end 
Output from program:
(-7.000000,24.000000)
(-7.000000,24.000000)
(-39.000000,-120.000000) ! should also be (-7.000000,24.000000)

Additional query words: 5.10 buglist5.10 fixlist1.00

Keywords :
Version : :5.1
Platform :
Issue type :


Last Reviewed: November 3, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.