Bug 24699 - READ with T format specifier fails on end-of-record condition
Summary: READ with T format specifier fails on end-of-record condition
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.0.3
Assignee: Jerry DeLisle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-06 23:42 UTC by Jerry DeLisle
Modified: 2005-11-13 06:32 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerry DeLisle 2005-11-06 23:42:20 UTC
The following reduced test case fails to correctly read the same line twice from the input file.  This was derived from the new Polyhedron test aermod.f90 which fails.

      character*132 :: rdfrm, runst1, foost
      character*1 :: runst(132)
      inunit = 11
      
      open (inunit, file = "AERMODTEST.INP")
      
      RDFRM = "(A080,T1,080A)" ! read the same line twice

      READ (INUNIT, '(A080,T1,080A)', end = 999)  RUNST1 , foost
      write (*,'(a80)') runst1
      write (*,'(a80)') foost
        
      READ (INUNIT, '(A080,T1,080A)', end = 999)  RUNST1 , foost
      write (*,'(a80)') runst1
      write (*,'(a80)') foost
         
      READ (INUNIT, '(A080,T1,080A)', end = 999)  RUNST1 , foost
      write (*,'(a80)') runst1
      write (*,'(a80)') foost
      goto 1000
 999     call exit ()
 
 1000  continue
       end

The input file is:

$ cat AERMODTEST.INP
CO STARTING
   TITLEONE A Simple Example Problem for the AERMOD Model with PRIME
   MODELOPT  CONC   FLAT
   AVERTIME  3  24  PERIOD 
   POLLUTID  SO2
   RUNORNOT  RUN
CO FINISHED
Comment 1 Jerry DeLisle 2005-11-11 20:19:27 UTC
Subject: Bug 24699

Author: jvdelisle
Date: Fri Nov 11 20:19:21 2005
New Revision: 106797

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106797
Log:
2005-11-09  Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/24699, 24700, 24719, 24785
	* io/transfer.c (read_sf): Remove incorrect statement that was
	clearing bytes_left.
	(formatted_transfer_scalar): Add handling of end-of-record
	condition, setting values correctly to backup.  Handle x format
	when doing non-advancing write.
	(st_read): Initialize current_record.

Modified:
    trunk/libgfortran/io/transfer.c

Comment 2 Jerry DeLisle 2005-11-11 20:31:12 UTC
Subject: Bug 24699

Author: jvdelisle
Date: Fri Nov 11 20:31:06 2005
New Revision: 106798

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106798
Log:
2005-11-11  Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/24719
	gfortran.dg/read_noadvance.f90: New test.
	
	PR libgfortran/24699
	gfortran.dg/fmt_t_2.f90: New test.
	
	PR libgfortran/24785
	gfortran.dg/read_x_eor.f90: New test.
	
	PR libgfortran/24584
	gfortran.dg/namelist_empty.f90: Rename test.

	PR libgfortran/24489
	gfortran/read_eor.f90: Rename test.

Added:
    trunk/gcc/testsuite/gfortran.dg/fmt_t_2.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_empty.f90
    trunk/gcc/testsuite/gfortran.dg/read_eor.f90
    trunk/gcc/testsuite/gfortran.dg/read_noadvance.f90
    trunk/gcc/testsuite/gfortran.dg/read_x_eor.f90

Comment 3 Jerry DeLisle 2005-11-12 22:22:58 UTC
Subject: Bug 24699

Author: jvdelisle
Date: Sat Nov 12 22:22:53 2005
New Revision: 106838

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106838
Log:
2005-11-12  Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/24699, 24700, 24719, 24785
	* io/transfer.c (read_sf): Remove incorrect statement that was
	clearing bytes_left.
	(formatted_transfer_scalar): Add handling of end-of-record
	condition, setting values correctly to backup.  Handle x format
	when doing non-advancing write.
	(st_read): Initialize current_record.

	PR libgfortran/24584
	* io/list_read.c (free_saved): Set saved_used to zero.

Modified:
    branches/gcc-4_0-branch/libgfortran/ChangeLog
    branches/gcc-4_0-branch/libgfortran/io/list_read.c
    branches/gcc-4_0-branch/libgfortran/io/transfer.c

Comment 4 Jerry DeLisle 2005-11-12 22:31:22 UTC
Subject: Bug 24699

Author: jvdelisle
Date: Sat Nov 12 22:31:18 2005
New Revision: 106839

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106839
Log:
2005-11-12  Jerry DeLisle <jvdelisle@gcc.gnu.org>

	PR libgfortran/24719
	*gfortran.dg/read_noadvance.f90: New test.
	
	PR libgfortran/24699
	*gfortran.dg/fmt_t_2.f90: New test.
	
	PR libgfortran/24785
	*gfortran.dg/read_x_eor.f90: New test.
	
	PR libgfortran/24584
	*gfortran.dg/namelist_empty.f90: Rename test.
	
	*gfortran.dg/f77/1832.f: Backport from 4.1.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/fmt_t_2.f90
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/namelist_empty.f90
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/read_noadvance.f90
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/read_x_eor.f90
Modified:
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/g77/1832.f

Comment 5 Jerry DeLisle 2005-11-12 23:13:11 UTC
Fixed in 4.0.3 and 4.1