Microsoft KB Archive/86741

= FIX: Concatenated Output to Binary File Causes Machine Halt =

Article ID: 86741

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q86741



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: kbfix KB86741

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.