Bug 34420 - List directed reads from file fails
Summary: List directed reads from file fails
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-10 16:37 UTC by Roger Hill-Cottingham
Modified: 2007-12-11 15:03 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
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 Roger Hill-Cottingham 2007-12-10 16:37:20 UTC
Consider the following example:

$cat myread.f
      integer n, i idmy
      character*2 typ(10)
      character*10 lab(10)
      character*40 wav(10)
      integer pos(10), neg(10), iat(10), ieq(10)
      complex val(10)
      
      open(10,file='XX',status='old')
      read(10,*,err=950,end=990) n
      do idmy=1,n
        read(10,*,err=950,end=990) i,typ(i),lab(i),
     $       pos(i),neg(i),
     $       ieq(i),wav(i),iat(i),val(i)
        
        write(*,*)i,typ(i),lab(i),
     $       pos(i),neg(i),
     $       ieq(i),wav(i),iat(i),val(i)
 
      enddo
      
      stop
 950  write(*,*)'error reading file'
      stop
 990  write(*,*)'unexpected end of file'
      end


and the file:
$cat XX
     2
      3 'R '  'R1        ' 
      3     48      0
'                                        '      0
(  0.4000000E-05,   0.000000    )
      4 'R '  'RR        ' 
     16     14      0
'                                        '      0
(  0.7830000    ,   0.000000    )


When compiled using GNU Fortran (GCC) 4.3.0 20071209 (experimental)
$ /usr/local/gcc-svn/bin/gfortran myread.f 
$ ./a.out
 error reading file

yet when using the system gfortran (GNU Fortran 95 (GCC) 4.1.2 (Gentoo 4.1.2)
)
I get:
$ gfortran myread.f 
$ ./a.out
           3 R R1                   3          48           0                                                    0 ( 4.0000000E-06,  0.000000    )
           4 R RR                  16          14           0                                                    0 ( 0.7830000    ,  0.000000    )

which is as expected.

This error has crept in sometime since 01 December, and appears to be in libgfortran, as programs compiled before 01 December also exhibit this error when run now, yet did not do so before I did my weekly build of gcc-4.3.0 on 09 December 2007.
Comment 1 Tobias Burnus 2007-12-10 18:49:02 UTC
I believe it is a duplicate of PR 34404 and was fixed yesterday. Please update libgfortran (or the whole GCC) and try again.

Thanks for the report.
Comment 2 Roger Hill-Cottingham 2007-12-11 15:03:01 UTC
Thanks everyone, revision 130775 fixes the problem.