public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails
@ 2012-12-27 23:39 burnus at gcc dot gnu.org
2012-12-27 23:43 ` [Bug fortran/55818] " jvdelisle at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-12-27 23:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
Bug #: 55818
Summary: Reading a REAL from a file which doesn't end in a new
line fails
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: jvdelisle@gcc.gnu.org
Reported by Elzbieta Burnett at
https://groups.google.com/d/msg/comp.lang.fortran/_HBMfv1lR3w/7b28oDQH2sUJ
The following program works for INTEGER but not for REAL. See also c.l.f for a
similar example.
The file looks like "1\n2\n3" without a "\n" after the 3. That fails for
list-directed read.
implicit none
integer :: stat
!integer :: var ! << works
real :: var ! << fails
open(99, file="test.dat", access="stream", form="unformatted", status="new")
write(99) "1", new_line("")
write(99) "2", new_line("")
write(99) "3"
close(99)
open(99, file="test.dat")
read (99,*, iostat=stat) var
if (stat /= 0 .or. var /= 1) call abort()
read (99,*, iostat=stat) var
if (stat /= 0 .or. var /= 2) call abort()
read (99,*, iostat=stat) var ! << FAILS: stat /= 0
if (stat /= 0 .or. var /= 3) call abort() ! << aborts here
close(99, status="delete")
end
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
@ 2012-12-27 23:43 ` jvdelisle at gcc dot gnu.org
2012-12-28 1:05 ` jvdelisle at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2012-12-27 23:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-12-27 23:43:04 UTC ---
I will have a look.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
2012-12-27 23:43 ` [Bug fortran/55818] " jvdelisle at gcc dot gnu.org
@ 2012-12-28 1:05 ` jvdelisle at gcc dot gnu.org
2012-12-28 1:07 ` jvdelisle at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2012-12-28 1:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-12-28 01:05:18 UTC ---
Possible patch, testing.
Index: list_read.c
===================================================================
--- list_read.c (revision 194731)
+++ list_read.c (working copy)
@@ -1429,6 +1429,7 @@ read_real (st_parameter_dt *dtp, void * dest, int
goto got_sign;
CASE_SEPARATORS:
+ case EOF:
unget_char (dtp, c); /* Single null. */
eat_separator (dtp);
return;
@@ -1484,6 +1485,7 @@ read_real (st_parameter_dt *dtp, void * dest, int
goto got_repeat;
CASE_SEPARATORS:
+ case EOF:
if (c != '\n' && c != ',' && c != '\r' && c != ';')
unget_char (dtp, c);
goto done;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
2012-12-27 23:43 ` [Bug fortran/55818] " jvdelisle at gcc dot gnu.org
2012-12-28 1:05 ` jvdelisle at gcc dot gnu.org
@ 2012-12-28 1:07 ` jvdelisle at gcc dot gnu.org
2012-12-28 9:23 ` burnus at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2012-12-28 1:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot |jvdelisle at gcc dot
|gnu.org |gnu.org
--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-12-28 01:07:09 UTC ---
Assigning to myself
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2012-12-28 1:07 ` jvdelisle at gcc dot gnu.org
@ 2012-12-28 9:23 ` burnus at gcc dot gnu.org
2012-12-28 14:26 ` jvdelisle at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-12-28 9:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-12-28 09:23:07 UTC ---
A similar issue exists for complex variables. Here, the value is correctly
read, but one still gets an EOF error.
Also with
character :: var
one runs into the problem. For
write(99) "1", new_line("")
write(99) "2", new_line("")
write(99) "3"
the last line is not read and stat == -1.
Test case for COMPLEX:
implicit none
integer :: stat
complex :: var
open(99, file="test.dat", access="stream", form="unformatted", status="new")
write(99) "(1,2)", new_line("")
write(99) "(2,3)", new_line("")
write(99) "(4,5)"
close(99)
open(99, file="test.dat")
read (99,*, iostat=stat) var
print *, stat, var
if (stat /= 0 .or. var /= cmplx(1,2)) call abort()
read (99,*, iostat=stat) var
print *, stat, var
if (stat /= 0 .or. var /= cmplx(2,3)) call abort()
read (99,*, iostat=stat) var ! << FAILS: stat /= 0, value is okay
print *, stat, var
if (stat /= 0 .or. var /= cmplx(4,5)) call abort()
close(99, status="delete")
end
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2012-12-28 9:23 ` burnus at gcc dot gnu.org
@ 2012-12-28 14:26 ` jvdelisle at gcc dot gnu.org
2012-12-28 19:12 ` jvdelisle at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2012-12-28 14:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-12-28 14:25:48 UTC ---
I suspected other types might have issue, but did not have time yesterday to
look at it. I will see what I can do here, time permitting.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2012-12-28 14:26 ` jvdelisle at gcc dot gnu.org
@ 2012-12-28 19:12 ` jvdelisle at gcc dot gnu.org
2013-01-01 16:00 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2012-12-28 19:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2012-12-28 19:11:54 UTC ---
I have submitted a revised patch for review that addresses character and
complex.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2012-12-28 19:12 ` jvdelisle at gcc dot gnu.org
@ 2013-01-01 16:00 ` burnus at gcc dot gnu.org
2013-01-02 17:09 ` jvdelisle at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-01-01 16:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-01-01 16:00:18 UTC ---
(In reply to comment #6)
> I have submitted a revised patch for review that addresses character and
> complex.
Namely, http://gcc.gnu.org/ml/fortran/2012-12/msg00197.html
I think that this patch is OK, except that "INF"/"INFINITY"/"NAN"/"NAN(0x123)"
does seem to suffer from similar issue.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2013-01-01 16:00 ` burnus at gcc dot gnu.org
@ 2013-01-02 17:09 ` jvdelisle at gcc dot gnu.org
2013-01-02 20:30 ` jvdelisle at gcc dot gnu.org
2013-01-05 19:20 ` jvdelisle at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2013-01-02 17:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2013-01-02 17:09:17 UTC ---
Author: jvdelisle
Date: Wed Jan 2 17:09:09 2013
New Revision: 194809
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194809
Log:
2013-01-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/55818
* io/list_read.c (read_real): Do not call hit_eof when EOF can be
treated as a value separator.
(parse_real): Likewise.
(read_logical): Likewise.
(read_character): Likewise.
(read_complex): Likewise.
Modified:
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/list_read.c
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (7 preceding siblings ...)
2013-01-02 17:09 ` jvdelisle at gcc dot gnu.org
@ 2013-01-02 20:30 ` jvdelisle at gcc dot gnu.org
2013-01-05 19:20 ` jvdelisle at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2013-01-02 20:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2013-01-02 20:29:35 UTC ---
Author: jvdelisle
Date: Wed Jan 2 20:29:28 2013
New Revision: 194819
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194819
Log:
2013-01-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/55818
* gfortran.dg/eof_4.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/eof_4.f90
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/55818] Reading a REAL from a file which doesn't end in a new line fails
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
` (8 preceding siblings ...)
2013-01-02 20:30 ` jvdelisle at gcc dot gnu.org
@ 2013-01-05 19:20 ` jvdelisle at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2013-01-05 19:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55818
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2013-01-05 19:20:01 UTC ---
Fixed on trunk.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-01-05 19:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-27 23:39 [Bug fortran/55818] New: Reading a REAL from a file which doesn't end in a new line fails burnus at gcc dot gnu.org
2012-12-27 23:43 ` [Bug fortran/55818] " jvdelisle at gcc dot gnu.org
2012-12-28 1:05 ` jvdelisle at gcc dot gnu.org
2012-12-28 1:07 ` jvdelisle at gcc dot gnu.org
2012-12-28 9:23 ` burnus at gcc dot gnu.org
2012-12-28 14:26 ` jvdelisle at gcc dot gnu.org
2012-12-28 19:12 ` jvdelisle at gcc dot gnu.org
2013-01-01 16:00 ` burnus at gcc dot gnu.org
2013-01-02 17:09 ` jvdelisle at gcc dot gnu.org
2013-01-02 20:30 ` jvdelisle at gcc dot gnu.org
2013-01-05 19:20 ` jvdelisle at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).