$ cat partial.f90 program main character(len=1) a(2) open(10, form="unformatted",status="unknown") write (10) 'a' rewind 10 a = 'b' read (10) a print *,a end program main $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../../gcc/trunk/configure --prefix=/home/ig25 --enable-languages=c,fortran Thread model: posix gcc version 4.2.0 20061020 (experimental) This should generate a runtime error. ifort gets this right: $ ifort partial.f90 $ ./a.out forrtl: severe (67): input statement requires too much data, unit 10, file /home/ig25/Krempel/Transfer/fort.10 Image PC Routine Line Source a.out 08085958 Unknown Unknown Unknown a.out 08085450 Unknown Unknown Unknown a.out 08084A0D Unknown Unknown Unknown a.out 080648C8 Unknown Unknown Unknown a.out 08064D6B Unknown Unknown Unknown a.out 08055937 Unknown Unknown Unknown a.out 080554B1 Unknown Unknown Unknown a.out 0804A239 Unknown Unknown Unknown a.out 0804A13C Unknown Unknown Unknown Unknown A7E40EA8 Unknown Unknown Unknown a.out 08049FF1 Unknown Unknown Unknown
Uh, I forgot the actual output from the program: $ gfortran partial.f90 $ ./a.out ab
Created attachment 12504 [details] preliminary patch
I had considered flipping the logic around on is_stream_io as you have done in the preliminary patch. The first versions of stream_io I was leaving the existing code completely untouched while testing out the overall approach. Now that we are in 4.3 this is a good time to do some cleanup. Overall, the prelminary patch approach looks good, but I have not tested yet.
Created attachment 12506 [details] updated patch In the previous patch, I had ommitted one test too many (the one for EOF). Here's an updated version.
(In reply to comment #3) Hi Jerry, > Now > that we are in 4.3 this is a good time to do some cleanup. Overall, the > prelminary patch approach looks good, but I have not tested yet. There's another reason why I want the cleanup: For implementing Intel record markers (PR 29568). Interleaving stream and record I/O would lead to so many if statements that I'd never get this right :-) Thomas
Subject: Bug 29627 Author: tkoenig Date: Tue Oct 31 20:58:26 2006 New Revision: 118341 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118341 Log: 2006-10-31 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/29627 * libgfortran.h: Add ERROR_SHORT_RECORD * runtime/error.c (translate_error): Add case for ERROR_SHORT_RECORD. * io/transfer.c (read_block_direct): Separate codepaths for stream and record unformatted I/O. Remove unneeded tests for standard input, padding and formatted I/O. If the record is short, read in as much data as possible, then raise the error. 2006-10-31 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/29627 * gfortran.dg/unf_short_record_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/unf_short_record_1.f90 Modified: trunk/gcc/testsuite/ChangeLog trunk/libgfortran/ChangeLog trunk/libgfortran/io/transfer.c trunk/libgfortran/libgfortran.h trunk/libgfortran/runtime/error.c
Fixed on trunk.
Subject: Bug 29627 Author: tkoenig Date: Fri Nov 3 11:22:27 2006 New Revision: 118453 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118453 Log: 2006-11-03 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/29627 Backport from trunk * libgfortran.h: Add ERROR_SHORT_RECORD * runtime/error.c (translate_error): Add case for ERROR_SHORT_RECORD. * io/transfer.c (read_block_direct): Separate codepaths for stream and record unformatted I/O. Remove unneeded tests for standard input, padding and formatted I/O. If the record is short, read in as much data as possible, then raise the error. 2006-11-03 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/29627 Backport from trunk * gfortran.dg/unf_short_record_1.f90: New test. Added: branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/unf_short_record_1.f90 Modified: branches/gcc-4_2-branch/gcc/testsuite/ChangeLog branches/gcc-4_2-branch/libgfortran/ChangeLog branches/gcc-4_2-branch/libgfortran/io/transfer.c branches/gcc-4_2-branch/libgfortran/libgfortran.h branches/gcc-4_2-branch/libgfortran/runtime/error.c
Fixed on 4.2 too; will need to regtest for backporting to 4.1.
Subject: Bug 29627 Author: tkoenig Date: Sat Nov 4 14:04:27 2006 New Revision: 118480 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118480 Log: 2006-11-04 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/29627 Backport from trunk * libgfortran.h: Add ERROR_SHORT_RECORD * runtime/error.c (translate_error): Add case for ERROR_SHORT_RECORD. * io/transfer.c (read_block_direct): Remove unneeded tests for standard input, padding and formatted I/O. If the record is short, read in as much data as possible, then raise the error. 2006-11-04 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/29627 Backport from trunk * gfortran.dg/unf_short_record_1.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/unf_short_record_1.f90 Modified: branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/libgfortran/ChangeLog branches/gcc-4_1-branch/libgfortran/io/transfer.c branches/gcc-4_1-branch/libgfortran/libgfortran.h branches/gcc-4_1-branch/libgfortran/runtime/error.c
Fixed on 4.1 as well, after regression-testing. Closing.