Bug 60810 - [4.7/4.8/4.9/4.10 Regression] list directed io from array results in end of file
Summary: [4.7/4.8/4.9/4.10 Regression] list directed io from array results in end of file
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.0
: P4 normal
Target Milestone: 4.7.4
Assignee: Jerry DeLisle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-10 17:31 UTC by Orion Poplawski
Modified: 2014-04-29 03:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.2
Known to fail: 4.9.0
Last reconfirmed: 2014-04-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Orion Poplawski 2014-04-10 17:31:19 UTC
This program:

program readstrlist
      character(len=80), dimension(2) :: ver
      integer :: a, b, c

      ver(1) = '285 383'
      ver(2) = '985'

      read( ver, *) a, b, c
      write ( *, *) a, b, c
end

Outputs:
At line 8 of file readstrlist.f90
Fortran runtime error: End of file

with:
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.9.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-isl=/builddir/build/BUILD/gcc-4.9.0-20140409/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.9.0-20140409/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.9.0 20140409 (Red Hat 4.9.0-0.9) (GCC) 

works with 4.8.2 and earlier and ifort version 14.0.2.
Comment 1 Jerry DeLisle 2014-04-11 01:54:49 UTC
Confirmed.

Works on 4.6, fails on 4.7, 4.8, and 4.9.

I have to think about this a bit.  I could see an end-of-record message would be possibly the right behavior since each array element is treated as a record.

On the other hand, ifort accepts this.  So I wonder what other compilers do.
Comment 2 Jakub Jelinek 2014-04-11 05:35:18 UTC
Is that the r208591 (and for 4.8 r208595) change that changed the behavior?
Comment 3 Jakub Jelinek 2014-04-11 09:12:01 UTC
The libgfortran change is in all of 4.7/4.8 branches and the trunk now I believe.
Comment 4 Jerry DeLisle 2014-04-11 19:41:49 UTC
(In reply to Jakub Jelinek from comment #3)
> The libgfortran change is in all of 4.7/4.8 branches and the trunk now I
> believe.

I am checking now. If so I will probably revert that previous patch.
Comment 5 Jerry DeLisle 2014-04-11 20:18:26 UTC
The breakage is at r208528, investigating.
Comment 6 Jerry DeLisle 2014-04-11 21:54:48 UTC
I would like to request the following be applied to the 4.9 release candidate if possible. It reverts a portion of the original patch that caused this regression.
I will then do this for 4.7, 4.8, 4.9, and 4.10.  Please advise.

Index: unit.c
===================================================================
--- unit.c	(revision 209325)
+++ unit.c	(working copy)
@@ -382,9 +382,7 @@
 is_trim_ok (st_parameter_dt *dtp)
 {
   /* Check rank and stride.  */
-  if (dtp->internal_unit_desc
-      && (GFC_DESCRIPTOR_RANK (dtp->internal_unit_desc) > 1
-	  || GFC_DESCRIPTOR_STRIDE(dtp->internal_unit_desc, 0) != 1))
+  if (dtp->internal_unit_desc)
     return false;
   /* Format strings can not have 'BZ' or '/'.  */
   if (dtp->common.flags & IOPARM_DT_HAS_FORMAT)
Comment 7 Jerry DeLisle 2014-04-12 00:05:13 UTC
Author: jvdelisle
Date: Sat Apr 12 00:04:41 2014
New Revision: 209329

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

	PR libfortran/60810
	io/unit.c (is_trim_ok): If internal unit is array, do not trim.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unit.c
Comment 8 Jerry DeLisle 2014-04-12 00:06:35 UTC
Fixed on trunk, waiting on 4.9, will proceed to 4.8 and 4.7
Comment 9 Jerry DeLisle 2014-04-12 18:42:46 UTC
Author: jvdelisle
Date: Sat Apr 12 18:42:15 2014
New Revision: 209338

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

	PR libfortran/60810
	io/unit.c (is_trim_ok): If internal unit is array, do not trim.

Modified:
    branches/gcc-4_9-branch/libgfortran/ChangeLog
    branches/gcc-4_9-branch/libgfortran/io/unit.c
Comment 10 Jerry DeLisle 2014-04-12 18:51:25 UTC
Author: jvdelisle
Date: Sat Apr 12 18:50:53 2014
New Revision: 209339

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

	PR libfortran/60810
	gfortran.dg/arrayio_13.f90: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/arrayio_13.f90
Modified:
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 11 Jerry DeLisle 2014-04-12 22:52:42 UTC
Author: jvdelisle
Date: Sat Apr 12 22:52:10 2014
New Revision: 209340

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

	Backport from mainline
	PR libfortran/60810
	io/unit.c (is_trim_ok): If internal unit is array, do not trim.

	Backport from mainline
	PR libfortran/60810
	gfortran.dg/arrayio_13.f90: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/arrayio_13.f90
Modified:
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/libgfortran/ChangeLog
    branches/gcc-4_8-branch/libgfortran/io/unit.c
Comment 12 Jerry DeLisle 2014-04-13 02:10:10 UTC
Author: jvdelisle
Date: Sun Apr 13 02:05:02 2014
New Revision: 209345

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

	Backport from mainline
	PR libfortran/60810
	gfortran.dg/arrayio_13.f90: New test.

	PR libfortran/60810
	io/unit.c (is_trim_ok): If internal unit is array, do not trim.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/arrayio_13.f90
Modified:
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/libgfortran/ChangeLog
    branches/gcc-4_7-branch/libgfortran/io/unit.c
Comment 13 Orion Poplawski 2014-04-16 15:20:10 UTC
Jakub - Could we get this into Fedora Rawhide?  Need it to fix a broken dep in plplot.  Thanks.
Comment 14 Jerry DeLisle 2014-04-29 03:14:07 UTC
Author: jvdelisle
Date: Tue Apr 29 03:13:34 2014
New Revision: 209888

URL: http://gcc.gnu.org/viewcvs?rev=209888&root=gcc&view=rev
Log:
2014-04-28  Jerry DeLisle  <jvdelisle@gcc.gnu>

	PR libfortran/60810
	* gfortran.dg/arrayio_13.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/arrayio_13.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 15 Jerry DeLisle 2014-04-29 03:15:12 UTC
Closing.