[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #38 from patchapp at dberlin dot org 2007-04-01 17:00 --- Subject: Bug number PR31052 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-04/msg00014.html -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #39 from jvdelisle at gcc dot gnu dot org 2007-04-01 18:32 --- Subject: Bug 31052 Author: jvdelisle Date: Sun Apr 1 18:32:20 2007 New Revision: 123403 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=123403 Log: 2007-04-01 Jerry DeLisle [EMAIL PROTECTED] PR libgfortran/31052 * io/open.c (test_endfile): Delete this function. (edit_modes): Delete call to test_endfile. (new_unit): Likewise. * io/io.h: Delete prototype for test_endfile. * io/transfer.c (next_record_r): Remove use of test_endfile. (st_read): Add test for end file condition and adjust status. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/io.h trunk/libgfortran/io/open.c trunk/libgfortran/io/transfer.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #40 from jvdelisle at gcc dot gnu dot org 2007-04-01 18:33 --- Subject: Bug 31052 Author: jvdelisle Date: Sun Apr 1 18:33:13 2007 New Revision: 123404 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=123404 Log: 2007-04-01 Jerry DeLisle [EMAIL PROTECTED] PR libgfortran/31052 * gfortran.dg/namelist_28.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/namelist_28.f90 Modified: trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #37 from anlauf at gmx dot de 2007-03-28 22:22 --- (In reply to comment #36) Closing, will not backport to 4.2 unless someone feels strongly about it. Jerry, I hate to bother you, but it is not really fixed. Add a comment line at the end of the namelist file gfcbug61a.nml, so that it reads: REPORT type='report1' / REPORT type='report2' / ! Now the last attempt to read this namelist fails again. Sorry, reopening this one... -- anlauf at gmx dot de changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|FIXED | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #35 from jvdelisle at gcc dot gnu dot org 2007-03-28 01:19 --- Subject: Bug 31052 Author: jvdelisle Date: Wed Mar 28 01:19:39 2007 New Revision: 123284 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=123284 Log: 2007-03-27 Jerry DeLisle [EMAIL PROTECTED] PR libgfortran/31052 * io/transfer.c (next_record_r): Do not call test_endfile if in namelist mode. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/transfer.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #36 from jvdelisle at gcc dot gnu dot org 2007-03-28 01:59 --- Closing, will not backport to 4.2 unless someone feels strongly about it. -- jvdelisle at gcc dot gnu dot org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #32 from jv244 at cam dot ac dot uk 2007-03-26 13:15 --- Unfortunately I don't have the SPEC test case to see to try to weed this out. have a look a comment #24 the sources are actually available -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #33 from spark at gcc dot gnu dot org 2007-03-26 16:54 --- (In reply to comment #31) Here is a new patch. I need someone to test on SPEC. It is very simple. Index: transfer.c === *** transfer.c (revision 123205) --- transfer.c (working copy) *** next_record_r (st_parameter_dt *dtp) *** 2228,2234 break; } ! if (dtp-u.p.current_unit-flags.access == ACCESS_SEQUENTIAL) test_endfile (dtp-u.p.current_unit); } --- 2228,2235 break; } ! if (dtp-u.p.current_unit-flags.access == ACCESS_SEQUENTIAL !!dtp-u.p.namelist_mode) test_endfile (dtp-u.p.current_unit); } This patch doesn't break 200.sixtrack (when added on top of the Jerry's previous patch above). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #34 from jvdelisle at gcc dot gnu dot org 2007-03-26 21:55 --- Regarding comment 24 and 32. I have that downloaded and tried to compile and there are duplications of subroutines and multiple main programs. As I get time, I intend to get it sorted out and add it to my testing here. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #31 from jvdelisle at gcc dot gnu dot org 2007-03-26 07:00 --- Here is a new patch. I need someone to test on SPEC. It is very simple. Index: transfer.c === *** transfer.c (revision 123205) --- transfer.c (working copy) *** next_record_r (st_parameter_dt *dtp) *** 2228,2234 break; } ! if (dtp-u.p.current_unit-flags.access == ACCESS_SEQUENTIAL) test_endfile (dtp-u.p.current_unit); } --- 2228,2235 break; } ! if (dtp-u.p.current_unit-flags.access == ACCESS_SEQUENTIAL !!dtp-u.p.namelist_mode) test_endfile (dtp-u.p.current_unit); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #30 from jvdelisle at verizon dot net 2007-03-24 19:02 --- Subject: Re: Bad IOSTAT values when readings NAMELISTs past EOF I will keep at it on this. It seems we have a conflict between the SPEC test that was failing and the namelist testcases. Unfortunately I don't have the SPEC test case to see to try to weed this out. What I will do is work on the patch i had before and send it to folks to test the SPEC portion. That may take a while, so please be patient. Sorry for the troubles. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #27 from anlauf at gmx dot de 2007-03-23 22:39 --- Created an attachment (id=13273) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13273action=view) Another variant of the bug -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #28 from anlauf at gmx dot de 2007-03-23 22:39 --- Created an attachment (id=13274) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13274action=view) Namelist for the modified demo -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #29 from anlauf at gmx dot de 2007-03-23 22:43 --- (In reply to comment #27) Jerry, with the latest variant of your patch I get a failing namelist read with the new reduced testcase gfcbug61a.f90 (uses gfcbug61a.nml). If I remove one of the entries in the namelist file, the second read succeeds. There must still be a problem with REWIND/BACKSPACE/READ. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #24 from jv244 at cam dot ac dot uk 2007-03-22 13:54 --- there is only one file on the web that matches: 'C READ IN HORIZONTAL AND VERTICAL MISALIGNMENT AND TILT' http://mad.home.cern.ch/frs/Source/DA/six.f -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #25 from jvdelisle at gcc dot gnu dot org 2007-03-22 20:38 --- Created an attachment (id=13255) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13255action=view) Untested patch to fix regression on sixtrack This patch reverts portions of the original patch and keeps a minimal set of changes to see if this clears the regression. The patch is against current trunk. If you could please test, I would appreciate. Regression tested on x86-64-Gnu/Linux I do not have a testcase here yet. If this fails, then I will try a further reduction. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #26 from jvdelisle at gcc dot gnu dot org 2007-03-23 00:13 --- Subject: Bug 31052 Author: jvdelisle Date: Fri Mar 23 00:13:19 2007 New Revision: 123139 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=123139 Log: 2007-03-22 Jerry DeLisle [EMAIL PROTECTED] PR libgfortran/31052 * file_pos.c: Update Copyright year. * io/open.c (test_endfile): Restore test_endfile to fix SPEC regression. Update Copyright year. * io/io.h: Same. * io/unix.c (is_special): Add missing type for this function. Update Copyright year. * io/transfer.c (next_record_r): Restore test_endfile. (st_read): Fix whitespace. Update Copyright year Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/file_pos.c trunk/libgfortran/io/io.h trunk/libgfortran/io/open.c trunk/libgfortran/io/transfer.c trunk/libgfortran/io/unix.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #23 from anlauf at gmx dot de 2007-03-20 08:51 --- (In reply to comment #22) Error 5001 would be ERROR_OPTION_CONFLICT. There are 18 different errors associated with that code. To find out which one, you must remove the iostat from the offending line so that gfortran will print the error message for you. OK, this is what I get with iostat removed and compiled with -fbacktrace: At line 264 of file ../../../../oo-model/mo_thinning.f90 Fortran runtime error: Missing format for FORMATTED data transfer Backtrace for this error: + function data_transfer_init (0x89C9B92) at line 1806 of file transfer.c + function __mo_thinning__read_nml_thin (0x83570AC) at line 264 of file mo_thinning.f90 [...] The code in question does a: rewind (nnml) [...] call position_nml (nnml, 'THINNING', ...) [...] read (nnml, nml=THINNING) ! This is line 264 The read is only executed when the position_nml succeeds. Another option is to use iomsg and get the string. Thanks, I did not know this F2003 feature. In that case I get for iomsg = read (nnml, nml=THINNING, iostat=ios, iomsg=iomsg) the following output: iostat =5001 iomsg = Missing format for FORMATTED data transfer No crash, of course, at least in the read statement. You can access the code base at gcc.gnu.org/viewcvs or better, I will bookmark that. download with anonymous svn. See instructions here: http://gcc.gnu.org/svn.html. If you do the svn approach, its very simple to get latest update and you are a few keystrokes from building it yourself. :) My next computer and internet connection will probably be powerful enough. ;-) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #20 from anlauf at gmx dot de 2007-03-19 22:59 --- (In reply to comment #19) Jerry, I tried FX's snapshot from today (20070319) and the example above works. A somewhat more twisted example which I have not yet been able to reduce leads to an IOSTAT value of 5001 (BTW: what does that value mean?) in the namelist read, although the subroutine position_nml succeeds. The file libgfortran is not in that distribution. Could you please put here these IOSTAT values? Nor are these in the .info files. Thanks! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #21 from sgk at troutmask dot apl dot washington dot edu 2007-03-20 01:47 --- Subject: Re: Bad IOSTAT values when readings NAMELISTs past EOF On Mon, Mar 19, 2007 at 10:59:25PM -, anlauf at gmx dot de wrote: --- Comment #20 from anlauf at gmx dot de 2007-03-19 22:59 --- (In reply to comment #19) Jerry, I tried FX's snapshot from today (20070319) and the example above works. A somewhat more twisted example which I have not yet been able to reduce leads to an IOSTAT value of 5001 (BTW: what does that value mean?) in the namelist read, although the subroutine position_nml succeeds. The file libgfortran is not in that distribution. Could you please put here these IOSTAT values? Nor are these in the .info files. Thanks! typedef enum { ERROR_FIRST = -3, /* Marker for the first error. */ ERROR_EOR = -2, ERROR_END = -1, ERROR_OK = 0, /* Indicates success, must be zero. */ ERROR_OS = 5000, /* Operating system error, more info in errno. */ ERROR_OPTION_CONFLICT, ERROR_BAD_OPTION, ERROR_MISSING_OPTION, ERROR_ALREADY_OPEN, ERROR_BAD_UNIT, ERROR_FORMAT, ERROR_BAD_ACTION, ERROR_ENDFILE, ERROR_BAD_US, ERROR_READ_VALUE, ERROR_READ_OVERFLOW, ERROR_INTERNAL, ERROR_INTERNAL_UNIT, ERROR_ALLOCATION, ERROR_DIRECT_EOR, ERROR_SHORT_RECORD, ERROR_CORRUPT_FILE, ERROR_LAST/* Not a real error, the last error # + 1. */ } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #22 from jvdelisle at gcc dot gnu dot org 2007-03-20 02:20 --- Error 5001 would be ERROR_OPTION_CONFLICT. There are 18 different errors associated with that code. To find out which one, you must remove the iostat from the offending line so that gfortran will print the error message for you. Another option is to use iomsg and get the string. You can access the code base at gcc.gnu.org/viewcvs or better, download with anonymous svn. See instructions here: http://gcc.gnu.org/svn.html. If you do the svn approach, its very simple to get latest update and you are a few keystrokes from building it yourself. :) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #18 from jvdelisle at gcc dot gnu dot org 2007-03-18 18:14 --- Subject: Bug 31052 Author: jvdelisle Date: Sun Mar 18 18:13:50 2007 New Revision: 123038 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=123038 Log: 2007-03-18 Jerry DeLisle [EMAIL PROTECTED] PR libgfortran/31052 * io/file_position (st_rewind): Fix comments. Remove use of test_endfile. Don't seek if already at 0 position. Use new is_special function to set endfile state. * io/open.c (test_endfile): Delete this function. * io/io.h: Delete prototype for test_endfile. Add prototype for is_special. * io/unix.c (is_special): New function. Fix whitespace. * io/transfer.c (next_record_r): Remove use of test_endfile. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/file_pos.c trunk/libgfortran/io/io.h trunk/libgfortran/io/open.c trunk/libgfortran/io/transfer.c trunk/libgfortran/io/unix.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #19 from jvdelisle at gcc dot gnu dot org 2007-03-18 18:17 --- Subject: Bug 31052 Author: jvdelisle Date: Sun Mar 18 18:17:24 2007 New Revision: 123039 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=123039 Log: 2007-03-18 Jerry DeLisle [EMAIL PROTECTED] PR libgfortran/31052 * gfortran.dg/namelist_27.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/namelist_27.f90 Modified: trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #17 from patchapp at dberlin dot org 2007-03-14 03:45 --- Subject: Bug number PR31052 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00892.html -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #15 from anlauf at gmx dot de 2007-03-08 08:24 --- (In reply to comment #14) Jerry, I don't have the ressources for a (re)build, so I will wait until it shows up in FX's daily binaries. Anyway, many thanks, and feel free to adjust the PR summary appropriately. From your patch it appears that the real culprit was the REWIND rather than the NAMELIST read. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #16 from jvdelisle at gcc dot gnu dot org 2007-03-09 07:37 --- hmm, I goofed, the patch in #14 does not fix this, scratch that. However, the problem is that test_endfile in st_rewind is incorrectly setting the AT_ENDFILE condition. I have a patch in progress. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #14 from jvdelisle at gcc dot gnu dot org 2007-03-08 05:51 --- Here is a patch. Herald, do you want to see if this fixes it for you. I tested here, but it does not hurt to test some more. Index: file_pos.c === --- file_pos.c (revision 122529) +++ file_pos.c (working copy) @@ -311,7 +311,6 @@ st_rewind (st_parameter_filepos *fpp) u-endfile = NO_ENDFILE; u-current_record = 0; - u-bytes_left = 0; u-strm_pos = 1; u-read_bad = 0; test_endfile (u); I will prepare a submittal to the list and a test case in the next few days, but this will get you going I hope. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #3 from anlauf at gmx dot de 2007-03-06 08:20 --- (In reply to comment #2) The value 5008 is listed in libgfortran.h as ERROR_ENDFILE. The -1 corresponds to ERROR_END. So, the return value of 5008 is telling you that you are trying to (initiate a?) read beyond the end of the file, which you admit to doing. I actually do not want to read beyond the end of file, I want gfortran to stay at the end of the file when trying to read the next record or namelist. All other compilers I have checked (xlf, ifort 7.x-9.x, g95) stay at the end of file. I find their behavior consistent with the F2003 standard, section 9.10.4: Execution of an input/output statement containing the IOSTAT= specifier causes the scalar-int-variable in the IOSTAT= specifier to become defined with (3) The processor-dependent negative integer value of the constant IOSTAT_END (13.8.2.5) if an end-of-file condition occurs and no error condition occurs, or (...) AFAIK, the IOSTAT values aren't documented in gfortran.texi. Someday, someone will get around to documenting them. The standard separates end-of-file, end-of-record, and error conditions. I don't think that EOF is necessarily an error condition. It would be nice if gfortran would conform with these other compilers. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #4 from anlauf at gmx dot de 2007-03-06 08:42 --- (In reply to comment #3) All other compilers I have checked (xlf, ifort 7.x-9.x, g95) stay at the end of file. I stand corrected with regard to xlf. It returns a documented recoverable error condition. I have to find out why the code in question that lead to the problem report does not properly recover with gfortran. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #5 from anlauf at gmx dot de 2007-03-06 10:22 --- (In reply to comment #4) I have to find out why the code in question that lead to the problem report does not properly recover with gfortran. It might be an interference with BACKSPACE, as the full code that lead me to the investigation does a scan through a namelist file and uses BACKSPACE here and then. Removing the BACKSPACE on the unit when the EOF condition occured helps somewhat, but then I encounter a funny error on a NAMELIST read: Fortran runtime error: Missing format for FORMATTED data transfer I thought that NAMELIST reads are list-directed. Anyway, I guess I have to produce a better testcase. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #6 from sgk at troutmask dot apl dot washington dot edu 2007-03-06 15:53 --- Subject: Re: Bad IOSTAT values when readings NAMELISTs past EOF On Tue, Mar 06, 2007 at 08:20:23AM -, anlauf at gmx dot de wrote: --- Comment #3 from anlauf at gmx dot de 2007-03-06 08:20 --- (In reply to comment #2) The value 5008 is listed in libgfortran.h as ERROR_ENDFILE. The -1 corresponds to ERROR_END. So, the return value of 5008 is telling you that you are trying to (initiate a?) read beyond the end of the file, which you admit to doing. I actually do not want to read beyond the end of file, I want gfortran to stay at the end of the file when trying to read the next record or namelist. All other compilers I have checked (xlf, ifort 7.x-9.x, g95) stay at the end of file. I find their behavior consistent with the F2003 standard, section 9.10.4: Execution of an input/output statement containing the IOSTAT= specifier causes the scalar-int-variable in the IOSTAT= specifier to become defined with (3) The processor-dependent negative integer value of the constant IOSTAT_END (13.8.2.5) if an end-of-file condition occurs and no error condition occurs, or (...) AFAIK, the IOSTAT values aren't documented in gfortran.texi. Someday, someone will get around to documenting them. The standard separates end-of-file, end-of-record, and error conditions. I don't think that EOF is necessarily an error condition. It would be nice if gfortran would conform with these other compilers. For whatever reason, you are hitting (2). (2) A processor-dependent positive integer value if an error condition occurs. At a guess, you get a -1 if you start a read from within the the file, and you hit the EOF. Once the EOF is hit, the file is probably positioned at a point beyond the EOF, the next attempt of a read is considered an error condition, so the 5008 is return. I saw your other email about BACKSPACE. I don't know what the expected behavior is with BACKSPACE and a file position that is at or exceeds the EOF marker. At a guess and knowing the vagueness of the Standard, this is probably processor-dependent. I think you're getting hit by 9.10.2(4) for F2003: (4) If the file specified in the input statement is an external record file, it is positioned after the endfile record. and BACKSPACE isn't doing its job with respect to Note 9.54. This is an area that Jerry knows. Perhaps, he has an opinion. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #7 from anlauf at gmx dot de 2007-03-06 21:51 --- Created an attachment (id=13153) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13153action=view) Revised demo Revised demo. New namelist for this demo follows. At some place, the input read gets garbled with gfortran, see the comment before the print statement in position_nml. Removing a few lines in the main program will hide this bug. Somehow the cycle REWIND/READ/BACKSPACE/(READ) confuses the runtime. -- anlauf at gmx dot de changed: What|Removed |Added Attachment #13148|0 |1 is obsolete|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #8 from anlauf at gmx dot de 2007-03-06 21:52 --- Created an attachment (id=13154) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13154action=view) Namelist -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #9 from anlauf at gmx dot de 2007-03-06 22:00 --- (In reply to comment #8) In the new example, when I comment out the BACKSPACE in position_nml for ios0 (EOF condition), the garbled output goes away. But in the large program (where this was extracted) this does not help; it dies later. (See comment #5). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #10 from jvdelisle at gcc dot gnu dot org 2007-03-07 03:37 --- Replying to comment #6. I am forming an opinion. Section 9.7 of the F2003 standard states: Backspacing over records written using list-directed or namelist formatting is prohibited. This implies to me that one should not mix BACKSPACE with a namelist file. However, I want to study the demo program a bit. This might be one of those correct behavior, outside the standard problems. Generally, reading past the last record gives an EOF and trying to read again is an error. The concept of a record with a namelist file does not seem to be compatible to me though. I will respond further after I have a chance to explore this a bit more. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #11 from jvdelisle at gcc dot gnu dot org 2007-03-07 03:38 --- I will take this one, but I am not confirming its a bug yet. -- jvdelisle at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |jvdelisle at gcc dot gnu dot |dot org |org Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2007-03-07 03:38:45 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #12 from jvdelisle at gcc dot gnu dot org 2007-03-07 04:45 --- The garbled text is because gfortran does not default initialize variable as some compilers do. The 'line' variable is not getting read because gfortran is getting an error on the read, so the it is not set to anything. Put a: line= at the top of the subroutine to get around that. After this you can see that IOS is set to -1, so 'line' is not read. I am now going to study the REWIND and BACKSPACE and see what we should be doing differently if anything. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #13 from jvdelisle at gcc dot gnu dot org 2007-03-07 06:40 --- AFAICT A backspace is not allowed for namelist files according to 9.7.1 I interpret this to mean this is invalid code. Further, Note 9.54 states that if the preceding record read is the EOF record, the BACKSPACE would position the file to before the EOF. You can think of this as in between the last record and the EOF record. So subsequent reads will again read the EOF record. From the demo program, you can see the repeated values of ios=-1, or the EOF condition returned by gfortran. So I believe the gfortran behavior is correct. Regardless, I do think REWIND should clear the EOF condition for namelist and I don't think it is. I confirm this as a bug. I am working on it. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #1 from anlauf at gmx dot de 2007-03-05 22:26 --- Created an attachment (id=13148) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13148action=view) Demo code The namelist file is here: http://gcc.gnu.org/bugzilla/attachment.cgi?id=13088 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052
[Bug libfortran/31052] Bad IOSTAT values when readings NAMELISTs past EOF
--- Comment #2 from kargl at gcc dot gnu dot org 2007-03-05 23:27 --- The value 5008 is listed in libgfortran.h as ERROR_ENDFILE. The -1 corresponds to ERROR_END. So, the return value of 5008 is telling you that you are trying to (initiate a?) read beyond the end of the file, which you admit to doing. AFAIK, the IOSTAT values aren't documented in gfortran.texi. Someday, someone will get around to documenting them. -- kargl at gcc dot gnu dot org changed: What|Removed |Added CC||kargl at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31052