From: Jerry D <jvdelisle2@gmail.com>
To: Harald Anlauf <anlauf@gmx.de>, sgk@troutmask.apl.washington.edu
Cc: gfortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, fortran] PR109662 Namelist input with comma after name accepted
Date: Fri, 12 May 2023 13:36:56 -0700 [thread overview]
Message-ID: <47439763-d673-5ea0-545b-40dd1200d5dd@gmail.com> (raw)
In-Reply-To: <5b8f724b-1a65-279b-cdc3-85e658d6ab2c@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 702 bytes --]
I plan to commit the following as simple.
The issue was a value was being modified on a short namelist read. After
tthe first read gives the correct EOF, a second read would give the
error but modify the variable.
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index 82664dc5f98..36d025949c2 100644
--- a/libgfortran/io/unit.c
+++ b/libgfortran/io/unit.c
@@ -504,6 +504,7 @@ set_internal_unit (st_parameter_dt *dtp, gfc_unit
*iunit, int kind)
iunit->current_record=0;
iunit->read_bad = 0;
iunit->endfile = NO_ENDFILE;
+ iunit->last_char = 0;
/* Set flags for the internal unit. */
The revised test case attached. It has been regression tested OK.
Regards,
Jerry
[-- Attachment #2: pr109662-a.f90 --]
[-- Type: text/x-fortran, Size: 708 bytes --]
! { dg-do run }
! { dg-options "-std=f2003" }
! PR109662-a semi-colon after namelist name accepted on input.
program testnmlread
implicit none
character(16) :: line = '&stuff; n = 759/'
character(100)::message
integer :: n, i, ioresult
namelist/stuff/n
message = ""
ioresult = 0
n = 99
read(line,nml=stuff,iostat=ioresult)
if (ioresult == 0) STOP 13 ! Should error with the semi-colon in there.
! Intentional short input (-> EOF)
line = "&stuff"
! Problem manifests on two bad reads on same string.
do i = 1, 6
n = -1
ioresult = 0
read (line,nml=stuff,iostat=ioresult)
if (n /= -1) STOP 24
if (ioresult == 0) STOP 25
end do
end program testnmlread
prev parent reply other threads:[~2023-05-12 20:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-06 3:41 Jerry D
2023-05-06 4:02 ` Steve Kargl
2023-05-06 18:15 ` Harald Anlauf
2023-05-06 22:37 ` Jerry D
2023-05-07 17:33 ` Jerry D
2023-05-07 18:33 ` Harald Anlauf
2023-05-08 0:13 ` Steve Kargl
2023-05-08 19:03 ` Harald Anlauf
2023-05-12 20:36 ` Jerry D [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47439763-d673-5ea0-545b-40dd1200d5dd@gmail.com \
--to=jvdelisle2@gmail.com \
--cc=anlauf@gmx.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=sgk@troutmask.apl.washington.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).