FIX: Logical IF in GOTO Loop Produces Unexpected ResultsLast reviewed: September 11, 1997Article ID: Q49731 |
4.00 4.10 5.00 5.10 | 4.10 5.00 5.10
MS-DOS | OS/2kbtool kbbuglist kbfixlist The information in this article applies to:
SYMPTOMSIn an application compiled with Microsoft FORTRAN, a logical IF statement in a GOTO loop produces incorrect results.
CAUSEThe compiler incorrectly optimized the IF statement in the GOTO loop.
RESOLUTIONTo address this problem, perform one of the following two steps:
STATUSMicrosoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.1, 5.0, and 5.1. This problem was corrected in FORTRAN PowerStation, version 1.0.
MORE INFORMATIONAs shown in the code sample below, the logical IF and GOTO loop compiles and runs without errors but it does not execute the correct lines of code. Because the GOTO 3100 statement in the logical IF statement is ignored, the program prints "at 3200, loop failed." To address this problem, compile the application without optimizations. The logical IF statement works correctly and the program prints "at 3100, loop worked".
Sample CodeC Compile options needed: See above
J = 03190 CONTINUE IF (J .GE. 3) GOTO 3100 ! The logical IF J = J + 1 GOTO 3190 ! The Goto loop3200 CONTINUE WRITE (*, *) 'at 3200, loop failed' STOP3100 CONTINUE WRITE (*, *) 'at 3100, loop worked' STOP END |
Additional reference words: 4.00 4.10 5.00 5.10 label run run-time
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |