Bug 29563 - Internal read loses data.
Summary: Internal read loses data.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: tree-ssa
: P3 normal
Target Milestone: 4.2.0
Assignee: Jerry DeLisle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-23 14:07 UTC by Keith Refson
Modified: 2006-10-27 20:57 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-24 02:12:14


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Refson 2006-10-23 14:07:47 UTC
gcc version 4.3.0 20061023 (experimental)
Mandriva 2006.0

The program

   program gfbread
     character(len=256), dimension(3) :: block_data = (/'1 2 3','4 5 6','7 8 9'/)
     real(kind=8), dimension(3,3) :: tmp_box
     read(block_data,*,iostat=iostat)((tmp_box(i,j),j=1,3),i=1,3)
     write(*,'(3F10.5)') ((tmp_box(i,j),j=1,3),i=1,3)
   end program gfbread

prints the output 

   1.00000   2.00000   3.00000
   4.00000   5.00000   6.00000
   7.00000   8.00000   0.00000

instead of the correct

   1.00000   2.00000   3.00000
   4.00000   5.00000   6.00000
   7.00000   8.00000   9.00000
Comment 1 Paul Thomas 2006-10-23 15:54:47 UTC
   program gfbread
     character(len=256), dimension(3) :: block_data = (/' 1 2 3',' 4 5 6',' 7 8 9'/)
     real(kind=8), dimension(3,3) :: tmp_box
     read(block_data,'(3(3f2.0/))',iostat=iostat)((tmp_box(i,j),j=1,3),i=1,3)
     write(*,'(3F10.5)') ((tmp_box(i,j),j=1,3),i=1,3)
   end program gfbread

works fine - the only difference in the code is the io call, so I would guess that something is awry with list_read.c

Any ideas, Jerry?

Paul

Comment 2 Jerry DeLisle 2006-10-24 02:12:14 UTC
I will have to investigate.  If you initialize the array tmpbox to something other than 0 you will see that the list read is not reading the 9th value at all.
Comment 3 Jerry DeLisle 2006-10-25 05:17:11 UTC
I have isolated the problem in list_read.c and am working on a patch.  It will be a day or two.
Comment 4 Jerry DeLisle 2006-10-26 04:35:56 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Thu Oct 26 04:35:45 2006
New Revision: 118059

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118059
Log:
2006-10-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* io/io.h (st_parameter_dt): Add new flag at_eof.
	* io/list_read.c (next_char): Set flag when EOF and return '\n' to
	signal EOR.  Check flag on next call and jump out.
	* io/unit.c (get_internal_unit): Initialize new flag.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/io.h
    trunk/libgfortran/io/list_read.c
    trunk/libgfortran/io/unit.c

Comment 5 Jerry DeLisle 2006-10-26 04:42:06 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Thu Oct 26 04:41:55 2006
New Revision: 118060

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118060
Log:
2006-10-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* gfortran.dg/arrayio_9.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/arrayio_9.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 6 Jerry DeLisle 2006-10-26 07:17:33 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Thu Oct 26 07:17:21 2006
New Revision: 118063

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118063
Log:
2006-10-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* io/list_read.c (next_char): Fix an error in previous commit.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c

Comment 7 Jerry DeLisle 2006-10-26 07:19:59 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Thu Oct 26 07:19:49 2006
New Revision: 118064

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118064
Log:
2006-10-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* gfortran.dg/arrayio_9.f90: Update test.
	* gfortran.dg/arrayio_19.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/arrayio_10.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/arrayio_9.f90

Comment 8 Jerry DeLisle 2006-10-27 01:04:15 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Fri Oct 27 01:04:02 2006
New Revision: 118079

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118079
Log:
2006-10-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* io/io.h (st_parameter_dt): Add new flag at_eof.
	* io/list_read.c (next_char): Set flag when EOF and return '\n' to
	signal EOR.  Check flag on next call and jump out.
	* io/unit.c (get_internal_unit): Initialize new flag.

Modified:
    branches/gcc-4_2-branch/libgfortran/ChangeLog
    branches/gcc-4_2-branch/libgfortran/io/io.h
    branches/gcc-4_2-branch/libgfortran/io/list_read.c
    branches/gcc-4_2-branch/libgfortran/io/unit.c

Comment 9 Jerry DeLisle 2006-10-27 02:03:51 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Fri Oct 27 02:03:34 2006
New Revision: 118080

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118080
Log:
2006-10-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* gfortran.dg/arrayio_9.f90: New test.
	* gfortran.dg/arrayio_19.f90: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/arrayio_10.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/arrayio_9.f90
Modified:
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 10 Jerry DeLisle 2006-10-27 02:08:40 UTC
Fixed on 4.2 and 4.3
Comment 11 Jerry DeLisle 2006-10-27 20:50:25 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Fri Oct 27 20:50:15 2006
New Revision: 118085

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118085
Log:
2006-10-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* gfortran.dg/error_recovery_2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/error_recovery_2.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 12 Jerry DeLisle 2006-10-27 20:57:34 UTC
Ignore comment 11.  Had the wrong PR number in ChangeLog entry when committing.
Comment 13 Jerry DeLisle 2006-10-27 21:41:06 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Fri Oct 27 21:40:54 2006
New Revision: 118087

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118087
Log:
2006-10-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* io/io.h (st_parameter_dt): Add new flag at_eof.
	* io/list_read.c (next_char): Set flag when EOF and return '\n' to
	signal EOR.  Check flag on next call and jump out.
	* io/unit.c (get_internal_unit): Initialize new flag.

Modified:
    branches/gcc-4_1-branch/libgfortran/ChangeLog
    branches/gcc-4_1-branch/libgfortran/io/io.h
    branches/gcc-4_1-branch/libgfortran/io/list_read.c
    branches/gcc-4_1-branch/libgfortran/io/unit.c

Comment 14 Jerry DeLisle 2006-10-27 21:42:49 UTC
Subject: Bug 29563

Author: jvdelisle
Date: Fri Oct 27 21:42:40 2006
New Revision: 118088

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118088
Log:
2006-10-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/29563
	* gfortran.dg/arrayio_9.f90: New test.
	* gfortran.dg/arrayio_19.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/arrayio_10.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/arrayio_9.f90
Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog