FIX: INDEX Function w/ Concatenation Yields Errors

Last reviewed: September 16, 1997
Article ID: Q85302
4.00 4.01 4.10 5.00 5.10 | 4.10 5.00 5.10
MS-DOS                   | OS/2
kbprg kbbuglist kbfixlist kbcode

The information in this article applies to:

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

SYMPTOMS

A program compiled with Microsoft FORTRAN version 4.0, 4.01, 4.1, 5.0, or 5.1 that contains the INDEX intrinsic function can generate incorrect results or hang the machine while running under MS-DOS. Under similar circumstances, the program may produce a protection violation while running under OS/2. This problem may occur when one of the parameters to the INDEX intrinsic function contains a string concatenation with a substring that is indexed with a variable. Changing the compiler options has no effect.

RESOLUTION

To resolve the problem, use a temporary string variable for the string concatenation prior to the INDEX call.

STATUS

Microsoft has confirmed this to be a problem in Microsoft FORTRAN versions 4.0, 4.01, 4.1, 5.0, and 5.1. This problem was corrected in FORTRAN PowerStation, version 1.9.

MORE INFORMATION

Sample Code 1

The following code reproduces the problem:

      character*1  a,  b
      a = '1'
      b = 'b'
      L = 1
      j = index('ab'//a(1:L),b)  !variable substring concatenation
      print*, j
      end

Sample Code 2

The following code does not cause the problem:

      character*1  a, b
      character*10 c

      a = '1'
      b = 'b'
      L = 1
      c = 'ab'//a(1:L)  !variable stores substring concatenation.
      j = index(c,b)    !variable used in INDEX statement.
      print*, j
      end


Additional reference words: 4.00 4.10 5.00 5.10 buglist4.00 buglist4.01
buglist4.10 buglist5.00 buglist5.10 fixlist1.00
KBCategory: kbprg kbbuglist kbfixlist kbcode
KBSubcategory: FORTLngIss
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 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.