Microsoft KB Archive/147756

= BUG: Error w/ CHAR in WRITE of Unformatted or Binary Output =

PSS ID Number: 147756

Article Last Modified on 11/2/1999

-

The information in this article applies to:


 * Microsoft Fortran PowerStation for Windows 95 and Windows NT 4.0

-



This article was previously published under Q147756



SYMPTOMS
Writing unformatted character output to a file with a CHAR expression causes an application error similar to the following:

Under Windows NT version 3.51:

Application Error - The instruction at 0x0040a9ba referenced memory at 0x00000041. The memory could not be read

Under Windows 95:

This program has performed an illegal operation and will be shut down.

If the problem persists, contact the program vendor.

-or-

Writing binary character output to a file with a CHAR expression causes an application error similar to the following:

Under Windows NT version 3.51:

Application Error - The instruction at 0x0040a773 referenced memory at 0x00000041. The memory could not be read.

Under Windows 95:

This program has performed an illegal operation and will be shut down.

If the problem persists, contact the program vendor.



RESOLUTION
Perform intermediate calculations in a temporary variable. Then use it in the CHAR expression.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The following code demonstrates the problem writing unformatted output:

Sample Code
C Compile options needed: none integer len len = 66 open(1,file='t.out',form='unformatted') C The following line causes an Access violation write(1) char(len-1) ! Comment this line for workaround

C To workaround the problem perform intermediate calculations C in a temporary variable and use it in the char expression.

C     i = len - 1         ! Uncomment this line for workaround C     write(1) char(i)    ! Uncomment this line for workaround

close(1) end The following code demonstrates the problem writing binary output:

Sample Code
C Compile options needed: none

integer len len = 66 open(1,file='t.out',form='binary')

C The following line causes an Access violation write(1) char(len-1) ! Comment this line for workaround

C To workaround the problem perform intermediate calculations C in a temporary variable and use it in the char expression.

C     i = len - 1         ! Uncomment this line for workaround C     write(1) char(i)    ! Uncomment this line for workaround

close(1) end

Additional query words: 4.00

Keywords: kbLangFortran KB147756

Technology: kbAudDeveloper kbFORTRANPower400NT kbFortranSearch kbZNotKeyword8

-

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

© 2004 Microsoft Corporation. All rights reserved.