BUG: Error w/ CHAR() in WRITE of Unformatted or Binary Output
ID: Q147756
|
The information in this article applies to:
-
Microsoft Fortran PowerStation for Windows 95 and Windows NT, version 4.0
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 : kbFortranPS kbLangFortran
Version : :4.0
Platform : NT WINDOWS
Issue type :