Bug 19595 - [4.0 only] eor does not work
Summary: [4.0 only] eor does not work
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Not yet assigned to anyone
URL:
Keywords: patch, wrong-code
: 19596 (view as bug list)
Depends on: 19568 20661
Blocks:
  Show dependency treegraph
 
Reported: 2005-01-23 20:50 UTC by Thomas Koenig
Modified: 2005-06-05 07:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.0
Known to fail:
Last reconfirmed: 2005-01-29 15:47:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2005-01-23 20:50:37 UTC
$ cat eor.f90
program main
  character*3 c
  open(12)
  write(12,'(A)') '123','456'
  rewind(12)
  read(12,'(A3)',advance='YES',eor=100) c
100 continue
end program main
$ gfortran eor.f90
$ ./a.out

Eor is only legal if advance='NO' is specified. It would be nice
if the above would generate an error.

        Thomas
Comment 1 Thomas Koenig 2005-01-24 20:37:37 UTC
*** Bug 19596 has been marked as a duplicate of this bug. ***
Comment 2 Thomas Koenig 2005-01-25 12:44:55 UTC
The following fixes the parsing issue:

--- transfer.c.orig     2005-01-25 13:43:28.000000000 +0100
+++ transfer.c  2005-01-25 13:43:35.000000000 +0100
@@ -1041,7 +1041,7 @@

   if (read_flag)
     {
-      if (ioparm.eor != 0 && advance_status == ADVANCE_NO)
+      if (ioparm.eor != 0 && advance_status != ADVANCE_NO)
        generate_error (ERROR_MISSING_OPTION,
                        "EOR specification requires an ADVANCE specification of
NO");

End-of-record handling for formatted read is generally broken, which
also includes eor (see PR 19568).
Comment 3 Thomas Koenig 2005-01-26 21:43:23 UTC
There are two parts to this bug.  The other is that eor is
that end-of-line processing is broken.  Here's a test case
with the patch from comment #2 applied:

$ cat eor_2.f90
program main
  character*4 c
  open(12)
  write(12,'(A)') '123','456'
  rewind(12)
  read(12,'(A4)',advance='NO',eor=100) c
  call abort
100 continue
end program main
$ gfortran eor_2.f90
$ ./a.out
Aborted
Comment 4 Andrew Pinski 2005-01-26 21:48:45 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01933.html>.
Comment 5 GCC Commits 2005-01-29 15:45:32 UTC
Subject: Bug 19595

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pbrook@gcc.gnu.org	2005-01-29 15:45:17

Modified files:
	gcc/testsuite  : ChangeLog 
	libgfortran    : ChangeLog 
	libgfortran/io : transfer.c 
Added files:
	gcc/testsuite/gfortran.dg: eor_1.f90 

Log message:
	2005-01-29  Thomas Koenig  <Thomas.Koenig@online.de>
	
	PR libfortran/19595
	* io/transfer.c (data_transfer_init): eor requires advance="NO".
	testsuite/
	* gfortran.dg/eor_1.f90:  New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4954&r2=1.4955
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.154&r2=1.155
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&r1=1.30&r2=1.31

Comment 6 Paul Brook 2005-01-29 15:46:07 UTC
Fixed.
Comment 7 Paul Brook 2005-01-29 15:47:00 UTC
Whoops, maybe not fixed.
Comment 8 Paul Brook 2005-01-29 15:47:32 UTC
.
Comment 9 Thomas Koenig 2005-02-02 21:07:59 UTC
The patch for the first part of the bug is applied,
the second part is still open.  Removed patch keyword
accordingly.

Comment 10 GCC Commits 2005-04-10 08:36:05 UTC
Subject: Bug 19595

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tkoenig@gcc.gnu.org	2005-04-10 08:35:40

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : transfer.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: eor_handling_1.f90 eor_handling_2.f90 
	                           eor_handling_3.f90 eor_handling_4.f90 
	                           eor_handling_5.f90 noadv_size.f90 
	                           pad_no.f90 

Log message:
	2005-04-10  Thomas Koenig <Thomas.Koenig@online.de>
	
	PR libfortran/17992
	PR libfortran/19568
	PR libfortran/19595
	PR libfortran/20005
	PR libfortran/20092
	PR libfortran/20131
	PR libfortran/20138
	PR libfortran/20661
	PR libfortran/20744
	* io/transfer.c (top level): eor_condition: New static variable.
	(read_sf): Remove unnecessary zeroing of buffer (there is enough
	information in its length).
	Return a string of length 0 (to be padded by caller) if EOR was
	seen previously.
	Remove erroneous special casing of EOR for standard input.
	Set eor_condition for non-advancing I/O if an end of line was
	detected.
	Increment ioparm.size if necessary.
	(formatted_transfer):  Skip the function if there is an EOR condition.
	(data_transfer_init):  Initialize eor_condition to zero (false).
	(next_record_r):  Clear sf_seen_eor if a \n has been seen already.
	(finalize_transfer):  If there is an EOR condition, raise the error.
	
	2005-04-10   Thomas Koenig  <Thomas.Koenig@online.de>
	
	* eor_handling_1.f90: New test case.
	* eor_handling_2.f90: New test case.
	* eor_handling_3.f90: New test case.
	* eor_handling_4.f90: New test case.
	* eor_handling_5.f90: New test case.
	* noadv_size.f90: New test case.
	* pad_no.f90: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&r1=1.188&r2=1.189
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&r1=1.35&r2=1.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5320&r2=1.5321
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_2.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_3.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_4.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_5.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/noadv_size.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pad_no.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 11 Thomas Koenig 2005-04-10 08:39:46 UTC
Fixed in 4.1.0, waiting for 4.0 to reopen.
Comment 12 GCC Commits 2005-05-03 19:40:09 UTC
Subject: Bug 19595

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tkoenig@gcc.gnu.org	2005-05-03 19:39:36

Modified files:
	libgfortran    : ChangeLog 
	libgfortran/io : transfer.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: eor_handling_1.f90 eor_handling_2.f90 
	                           eor_handling_3.f90 eor_handling_4.f90 
	                           eor_handling_5.f90 noadv_size.f90 
	                           pad_no.f90 

Log message:
	2005-05-03  Thomas Koenig <Thomas.Koenig@online.de>
	
	Backport from mainline:
	PR libfortran/17992
	PR libfortran/19568
	PR libfortran/19595
	PR libfortran/20005
	PR libfortran/20092
	PR libfortran/20131
	PR libfortran/20661
	PR libfortran/20744
	* io/transfer.c (top level): eor_condition: New static variable.
	(read_sf): Remove unnecessary zeroing of buffer (there is enough
	information in its length).
	Return a string of length 0 (to be padded by caller) if EOR was
	seen previously.
	Remove erroneous special casing of EOR for standard input.
	Set eor_condition for non-advancing I/O if an end of line was
	detected.
	Increment ioparm.size if necessary.
	(formatted_transfer):  Skip the function if there is an EOR condition.
	(data_transfer_init):  Initialize eor_condition to zero (false).
	(next_record_r):  Clear sf_seen_eor if a \n has been seen already.
	(finalize_transfer):  If there is an EOR condition, raise the error.
	
	2005-05-03  Thomas Koenig  <Thomas.Koenig@online.de>
	
	Backport from mainline:
	* eor_handling_1.f90: New test case.
	* eor_handling_2.f90: New test case.
	* eor_handling_3.f90: New test case.
	* eor_handling_4.f90: New test case.
	* eor_handling_5.f90: New test case.
	* noadv_size.f90: New test case.
	* pad_no.f90: New test case.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.163.2.22&r2=1.163.2.23
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/transfer.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.32.2.2&r2=1.32.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.156&r2=1.5084.2.157
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_1.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_2.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_3.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_4.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/eor_handling_5.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/noadv_size.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/pad_no.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.6.1

Comment 13 Thomas Koenig 2005-05-03 19:45:36 UTC
Patch committed to 4.0.1.  Fixed.