[Bug fortran/78351] comma not terminating READ of formatted input field - ok in 4.1.7, not 4.4.7- maybe related to 25419?
sgk at troutmask dot apl.washington.edu
gcc-bugzilla@gcc.gnu.org
Thu Nov 17 03:02:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78351
--- Comment #20 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Nov 17, 2016 at 01:44:45AM +0000, sgk at troutmask dot
apl.washington.edu wrote:
>
> In the above, you are hitting an end-of-record. I would need
> to go read the Standard to see what happens in this situation.
> I suspect that this may be Standard conforming, but the variables
> i and j are undefined and technically cannot be referenced until
> the variables become defined.
The acceptance of comma is a pox upon the world.
The following should simply exit upon execution,
instead prints ' 1 2'
program foo
open(unit=10, file='zxc')
read(10, '(2I10)', eor=3, advance='no') i,j
print *, i, j
stop
3 continue
end program foo
where the file 'zxc' contains the line
1,2,3,,,,
gfortran is definitely doing the right thing with your
original code. Using Fortran ability to report errors
shows
program foo
integer k
character(len=80) s, t
s = '1,2,3,,,,'
read(s, '(2I10)', err=3, iostat=k, iomsg=t) i,j
print *, i, j
stop
3 continue
print *, k, trim(t)
end program foo
% gfc7 -o z c.f90
% ./z
5010 Bad value during integer read
More information about the Gcc-bugs
mailing list