FIX: Intrinsic Functions in Substring Evaluation Fail

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

The information in this article applies to:

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

SYMPTOMS

An application developed in Microsoft FORTRAN that uses a complicated expression that involves intrinsic functions to calculate substring indexes generates incorrect results.

RESOLUTION

Simplify the expression used to specify the substring index by using one or more temporary variables to store intermediate results of the computation.

STATUS

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

MORE INFORMATION

The following program writes the string "B" to the display instead of the correct string "BCDEF."

Sample Code

C Compiler options required: None

      CHARACTER *20 A, B
      B = 'ABCDEFGHIJKLMNOP'
      I = 2
      J = 6
      A = B(I:(I + IDIM(J, 2)))
      WRITE(*,*) A
      END

The following code demonstrates one solution to the problem.

Sample Code

C Compiler options required: None

      PROGRAM STRING
      CHARACTER *20 A, B
      B='ABCDEFGHIJKLMNOP'
      I = 2
      J = 6
      K = I + IDIM(J, 2)
      A = B(I:K)
      WRITE(*,*) A
      END


Additional reference words: 4.00 4.01 4.10 5.00 5.10
KBCategory: kbtool kbfixlist kbbuglist kberrmsg
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.