GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 34560 - [4.3 Regression] I/O internal read: END expected, but no failure
Summary: [4.3 Regression] I/O internal read: END expected, but no failure
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Thomas Koenig
URL:
Keywords: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-12-22 19:48 UTC by Tobias Burnus
Modified: 2007-12-26 03:48 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-12-22 21:57:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-12-22 19:48:37 UTC
The following program should print "OK". This is a regression as gfortran 4.1.3 and 4.2.2 print "OK" and not "FAIL" as gfortran 4.3.0.

(Found using the Fortran Company Fortran 90 Test Suite (Lite), Version 1.4)

implicit none
integer :: i
! NAME_FIELD is an internal file.
CHARACTER * 80 :: NAME_FIELD
integer::name_array(17)=0
do i=1,16
  write(name_field(5*i-4:5*i),"(i5)")i
end do
! If the array NAME_ARRAY has more than 16 elements,
!   an end-of-file condition will occur and the statement
!   labeled 98 will be executed next.
READ (NAME_FIELD, 100, END=98) NAME_ARRAY
100 FORMAT (16I5)
97 print*,'FAIL - expected END=98'
stop
98 print*,'OK'
end
Comment 1 Thomas Koenig 2007-12-22 20:35:26 UTC
Confirmed.
Comment 2 Thomas Koenig 2007-12-22 20:40:30 UTC
Simplified test case:

$ cat eof.f90 
program main
  character(len=2) :: line
  character(len=1) :: a(3)
  line = 'ab'
  read (line,'(A)',end=99) a
  stop
  99 continue 
end program main
$ gfortran -g eof.f90 
$ gdb ./a.out
GNU gdb 6.6.90.20070912-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/i686/cmov/libthread_db.so.1".
(gdb) r
Starting program: /tmp/a.out 

Program received signal SIGSEGV, Segmentation fault.
0xb7da6665 in memcpy () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0  0xb7da6665 in memcpy () from /lib/i686/cmov/libc.so.6
#1  0xb7f493a4 in *_gfortrani_read_sf (dtp=0xbfd46074, length=0xbfd45dd8, 
    no_error=0) at ../../../../gcc/trunk/libgfortran/io/transfer.c:169
#2  0xb7f49574 in *_gfortrani_read_block (dtp=0xbfd46074, length=0xbfd45dd8)
    at ../../../../gcc/trunk/libgfortran/io/transfer.c:318
#3  0xb7f47328 in *_gfortrani_read_a (dtp=0xbfd46074, f=0x8050568, 
    p=0xbfd461a7 "·ÈaÔ¿9\207\004\b\001", length=1)
    at ../../../../gcc/trunk/libgfortran/io/read.c:248
#4  0xb7f4ad4e in formatted_transfer_scalar (dtp=0xbfd46074, 
    type=BT_CHARACTER, p=0xbfd461a7, len=1, size=1)
    at ../../../../gcc/trunk/libgfortran/io/transfer.c:1121
#5  0xb7f4b81e in formatted_transfer (dtp=0xbfd46074, type=BT_CHARACTER, 
    p=0xbfd461a5, kind=1, size=1, nelems=3)
    at ../../../../gcc/trunk/libgfortran/io/transfer.c:1366
#6  0xb7f484de in *_gfortran_transfer_array (dtp=0xbfd46074, desc=0xbfd46188, 
    kind=1, charlen=1) at ../../../../gcc/trunk/libgfortran/io/transfer.c:1518
#7  0x080486d1 in main () at eof.f90:5
Comment 3 Jerry DeLisle 2007-12-23 22:11:13 UTC
Thomas, I confirmed its my patch to transfer.c for pr31501 (r124266).  easy fix is to just revert it.  Maybe we can check length before we do the read.
Comment 4 Jerry DeLisle 2007-12-26 03:41:21 UTC
Subject: Bug 34560

Author: jvdelisle
Date: Wed Dec 26 03:41:06 2007
New Revision: 131178

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

	PR libfortran/34560
	* gfortran.dg/read_eof_5.f90: New test.

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

Comment 5 Jerry DeLisle 2007-12-26 03:48:43 UTC
Fixed on trunk.  Thanks for the report and test cases.