[Bug libfortran/59727] [4.7/4.8/4.9 Regression] reading from character string returns end of file

kargl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 9 00:26:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59727

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
> This is due to r166180:
> 
> Author:	jb
> Date:	Tue Nov 2 12:56:38 2010 UTC (3 years, 2 months ago)
> Changed paths:	4
> Log Message: PR 45629 Remove usage of setjmp/longjmp

Note, it may not be a regression, but I need to find time to
go read the standard.  Consider the modified program:

      CHARACTER*40 LINE, msg
      LINE(1:20)=' 12,30.0,10.5,0     '
      print *, '>',trim(line),'<'
      READ (LINE,*,err=10,iomsg=msg) I1,R1,R2,I2
      WRITE (*,1000) I1,R1,R2,I2
   10 print *, i1, r1, r2, i1, msg
 1000 FORMAT (I4,2F10.1,I4)
      END

troutmask:sgk[206] gfc4x -o z p.f && ./z
 > 12,30.0,10.5,0     @Õÿÿÿ<
At line 8 of file p.f
Fortran runtime error: End of file

After the assignment to line(1:20), I don't remember if the
standard requires the remaining space to be blank padded.
The problem is that line(21:40) contains whatever is in memory
as demonstrated by the 'print *,...' statement.  I suspect that
we are missing a eat_line() (or whatever the function is named).

One workaround is to set line='' as the first line of code.


More information about the Gcc-bugs mailing list