FIX: Concatenated Output to Binary File Causes Machine Halt

ID: Q86741


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 query words: 5.10 buglist5.10 fixlist1.00

Keywords :
Version : :5.1
Platform :
Issue type :


Last Reviewed: November 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.