BUG: /Ox and /4Ya Options Together Cause Incorrect Results

Last reviewed: April 9, 1996
Article ID: Q149517
The information in this article applies to:
  • Microsoft Fortran PowerStation for Windows 95 and Windows NT, version 4.0

SYMPTOMS

Compiling source code that performs arithmetic calculations along with the /Ox and /4Ya compiler options together creates object code that may produce incorrect arithmetic calculation results at run time.

RESOLUTION

Do not use the /Ox and /4Ya compiler options together.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Sample Code to Illustrate Problem

C Compile options needed: /Ox /4Ya

   REAL*8 a(3), x, y

   a(1) = -1.D0
   a(2) = -2.D0
   a(3) = -3.D0

   x = 0.D0
   y = 0.23D0

   a(3) = 1.D0/SQRT(1.D0+x*x+y*y)
   a(1) = x*a(3)
   a(2) = y*a(3)

   PRINT *,'a(1) = ',a(1)
   PRINT *,'a(2) = ',a(2)
   PRINT *,'a(3) = ',a(3)

   END

Correct Output

a(1) =   0.000000000000000E+000
a(2) =   2.241476929214269E-001
a(3) =   9.745551866148997E-001

Output with /Ox /4Ya

a(1) =   0.000000000000000E+000
a(2) =   2.241476929214269E-001
a(3) =   2.241476929214269E-001


Additional reference words: 4.00
KBCategory: kbprg kbbuglist
KBSubcategory: CodeGen



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 9, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.