FIX: Substring Concatenation in Test Generates Incorrect Code

Last reviewed: September 11, 1997
Article ID: Q39849
4.10 5.00 5.10 MS-DOS kbusage kbfixlist kbbuglist

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, versions 4.1, 5.0, and 5.1

SYMPTOMS

The following FORTRAN program produces incorrect results and causes the machine to hang:

        CHARACTER STRNG1*9, STRNG2*9
        INTEGER N
        LOGICAL SAME
        N=4
        STRNG1 = '123456789'
        STRNG2 = 'ABCDEFGHI'
        SAME = 'ZZ'//STRNG1(1:N) .EQ. STRNG2(1:N+2)
        WRITE(*,*) 'ZZ'//STRNG1(1:N)
        WRITE(*,*) STRNG2(1:N+2)
        WRITE(*,*) SAME
        END

The correct output should be as follows:

       ZZ1234
       ABCDEF
       F

The actual output is as follows:

       ZZ1234
       ABCDEF
       T

CAUSE

The code causes the machine to hang. Compiling without optimization had no effect. The problem is that bad code is generated for the substrings on the logical test line. Here the two substrings must be evaluated and incorrect code is being generated. If "N" in the concatenated substring is replaced with the numerical equivalent "4" or if the concatenation is executed previously and a temporary variable is used for the logical test, correct code is generated and everything executes correctly.

It has been reported that this code does not hang the system right away. You can execute internal MS-DOS commands, but as soon as you try any external commands, the system hangs.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in FORTRAN PowerStation.


Additional reference words: 4.10 5.00 5.10
KBCategory: kbusage 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.