FIX: Concatenated Output to Binary File Causes Machine Halt

Last reviewed: September 16, 1997
Article ID: Q86741
5.10 | 5.10 MS-DOS | OS/2 kbprg kbfixlist kbbuglist kbcode

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, version 5.1
  • Microsoft FORTRAN for OS/2, version 5.1

SYMPTOMS

Applications repeatedly output concatenated strings to binary files may cause the machine to halt under MS-DOS or a Trap D protection violation under OS/2.

RESOLUTION

Assign the result of the string concatenation to a temporary variable to avoid the use of concatenation directly in WRITE statements to binary files. Or use commas to separate the output data rather than concatenation.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN version 5.1. This problem was corrected in FORTRAN PowerStation, version 1.0.

MORE INFORMATION

The following code can be used to demonstrate the problem.

Sample Code #1

The following code reproduces the problem:

      character*100 aline

      aline = 'a'
      open(1,file='test.dat',form='binary')

      k = 100

      do i=1,10000
        print*, i
        write(1) aline(:k)//'b'
      end do

      end

Sample Code #2

The following code will correct the problem:

      character*100 aline
      character*101 bline

      aline = 'a'
      open(1,file='test.dat',form='binary')

      k = 100

      do i=1,10000
        print*, i
        bline = aline(:k)//'b'
        write(1) bline
      end do

      end


Sample Code #3

The following code will also correct the problem:

      character*100 aline

      aline = 'a'
      open(1,file='test.dat',form='binary')

      k = 100

      do i=1,10000
        print*, i
        write(1) aline(:k),'b'
      end do

      end


Additional reference words: 5.10 buglist5.10 fixlist1.00
KBCategory: kbprg kbbuglist kbfixlist
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.