FIX: Optimization Problem, Assignment Not Made, Write Fails

Last reviewed: September 11, 1997
Article ID: Q39514
4.01 4.10 5.00 | 4.10 5.00
MS-DOS         | OS/2
kbtool kbfixlist kbbuglist

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, versions 4.01, 4.1, 5.0
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0

SYMPTOMS

An application copies an incorrect value from an array in a COMMON block. An element of an array specified as an argument to a subprogram is the destination for the copied value.

CAUSE

The application passes an array to a subprogram through an argument list and shares another array with the subprogram through a COMMON block. The compile command line includes the /Od compile option switch to disable optimizations.

RESOLUTION

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

  • Remove the /Od compiler option switch and compile the application with default optimizations (the /Ox compiler option switch accomplishes the same purpose).

    -or-

  • Compile the code with only the common subexpression optimization by specifying the /Odc compiler option switch.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN versions 4.01, 4.1, and 5.0 for MS-DOS and versions 4.1 and 5.0 for OS/2. This problem was corrected in FORTRAN version 5.1.

MORE INFORMATION

The following code demonstrates the problem.

Sample Code

C Compiler options needed: None

      IMPLICIT DOUBLE PRECISION (A-H, O-Z)
      DIMENSION TMP(5000, 1)
      COMMON /BAD/ RBAD(3, 3)
      RBAD(1, 1) = 1
      CALL TRY1(TMP)
      WRITE(0, *) TMP(1, 1)
      END
C
      SUBROUTINE TRY1(TMP)
      IMPLICIT DOUBLE PRECISION (A-H, O-Z)
      DIMENSION TMP(5000, 1)
      COMMON /BAD/ RBAD(3, 3)
      I = 1
      K = 1
      TMP(I, K) = RBAD(K, I)
      RETURN
      END


Additional reference words: 4.01 4.10 5.00 buglist4.01 buglist4.10
buglist5.00 fixlist5.10
KBCategory: kbtool kbfixlist kbbuglist
KBSubCategory: FLIss
Solution Type : kbfix


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: September 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.