[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 Jerry DeLisle changed: What|Removed |Added Resolution|--- |FIXED Status|REOPENED|RESOLVED --- Comment #22 from Jerry DeLisle --- Closing.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #21 from CVS Commits --- The master branch has been updated by Jerry DeLisle : https://gcc.gnu.org/g:96cc09dea48b562a0fc93d43fb3b702ac20b89fd commit r14-802-g96cc09dea48b562a0fc93d43fb3b702ac20b89fd Author: Jerry DeLisle Date: Fri May 12 13:38:25 2023 -0700 Fortran: Revise a namelist test case. PR fortran/109662 gcc/testsuite/ChangeLog: * gfortran.dg/pr109662-a.f90: Add a section to verify that a short namelist read does not modify the variable.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #20 from CVS Commits --- The master branch has been updated by Jerry DeLisle : https://gcc.gnu.org/g:cf3b032b8fb681516ccacbe3689f1cad43a1773a commit r14-801-gcf3b032b8fb681516ccacbe3689f1cad43a1773a Author: Jerry DeLisle Date: Fri May 12 12:23:00 2023 -0700 Fortran: Initialize last_char for internal units. PR fortran/109662 libgfortran/ChangeLog: * io/unit.c (set_internal_unit): Set the internal unit last_char to zero so that previous EOF characters do not influence the next read.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #19 from Jerry DeLisle --- Created attachment 55024 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55024&action=edit An enhanced test case This test case from Herald illustrates a variety of combinations. Giving: $ gfc -std=f2018 pr109662-xx.f90 $ ./a.out Compiler version = GCC version 14.0.0 20230506 (experimental) 1-line: > < 759 0 2-line/left: > < 759 0 2-line/right: > < 759 0 1-line: >!< -1 -1 2-line/left: >!< -1 0 2-line/right: >!< 759 0 1-line: >/< -1 0 2-line/left: >/< -1 0 2-line/right: >/< -1 0 1-line: >,< 7595010 2-line/left: >,< 7595010 2-line/right: >,< 7595010 1-line: >;< 7595010 2-line/left: >;< 7595010 2-line/right: >;< 7595010 1-line: tab 759 0 2-line/left: tab 759 0 2-line/right: tab 759 0 1-line: lf 759 0 2-line/left: lf 759 0 2-line/right: lf 759 0 1-line: ret 759 0 2-line/left: ret 759 0 2-line/right: ret 759 0
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 Jerry DeLisle changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|FIXED |--- --- Comment #18 from Jerry DeLisle --- Reopening to address other potential issues.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #17 from CVS Commits --- The master branch has been updated by Jerry DeLisle : https://gcc.gnu.org/g:d46b3db4bd016a3eccfb933c81c7a9d87c0ad403 commit r14-566-gd46b3db4bd016a3eccfb933c81c7a9d87c0ad403 Author: Jerry DeLisle Date: Sun May 7 18:54:55 2023 -0700 Fortran: Reject semicolon after namelist name. PR fortran/109662 libgfortran/ChangeLog: * io/list_read.c: Add check for a semicolon after a namelist name in read input. Issue a runtime error message. gcc/testsuite/ChangeLog: * gfortran.dg/pr109662-a.f90: New test.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #16 from john.harper at vuw dot ac.nz --- Saw this only after my previous 2 replies, A semicolon in a namelist is not a separator between Fortran statements, but it takes the place of a comma between values when decimal='COMMA' in an open, read or write statement according to f2003 10.9 and 10.10, and 9.5.1 C928 says decimal= and nml= may both appear in a data transfer statement. John On Sun, 7 May 2023, jvdelisle at gcc dot gnu.org wrote: > Date: Sun, 7 May 2023 18:35:46 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it > Resent-Date: Mon, 8 May 2023 06:36:00 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 > > --- Comment #13 from Jerry DeLisle --- > (In reply to Jerry DeLisle from comment #12) > > That recent patch regression tests fine. I should mention, there is one of our > original test cases in gfortran.dg that does use a comma. We definitely have > see the comma used, but I have never seen a semi-colon. I think because it is > a newer feature allowing semicoln separators between FORTRAN statements on a > single line. (?) > > Regardless, I am ready to push this out to trunk. > > -- > You are receiving this mail because: > You reported the bug. > -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #15 from john.harper at vuw dot ac.nz --- Sorry: what I should have said was that If and only if a comma after a namelist name was a pre-2003 possibility for gfortran then it makes sense to reject a semicolon there when the decimal edit mode is COMMA, which first got into the standard with f2003. John H On Sun, 7 May 2023, john.harper at vuw dot ac.nz wrote: > Date: Sun, 7 May 2023 21:46:33 + > From: john.harper at vuw dot ac.nz > To: John Harper > Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it > Resent-Date: Mon, 8 May 2023 09:46:44 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 > > --- Comment #14 from john.harper at vuw dot ac.nz --- > Rejecting a semicolon after the namelist name even if the decimal edit > mode is COMMA makes sense because COMMA was first allowed in f2003, > provided that semicolons in namelist were a pre-f2003 legacy possibility. > > John H > > On Sun, 7 May 2023, jvdelisle at gcc dot gnu.org wrote: > >> Date: Sun, 7 May 2023 18:14:23 + >> From: jvdelisle at gcc dot gnu.org >> To: John Harper >> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it >> Resent-Date: Mon, 8 May 2023 06:14:37 +1200 (NZST) >> Resent-From: >> >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 >> >> --- Comment #12 from Jerry DeLisle --- >> A additional adjustment to reject the semi-colon always. >> >> diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c >> index 78bfd9e8787..db3330060ce 100644 >> --- a/libgfortran/io/list_read.c >> +++ b/libgfortran/io/list_read.c >> @@ -3598,9 +3598,9 @@ find_nml_name: >> >> /* A trailing space is required, we allow a comma with std=gnu. */ >> c = next_char (dtp); >> - if (c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) >> + if ((c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) || c == ';') >> generate_error (&dtp->common, LIBERROR_READ_VALUE, >> - "Comma after namelist name not allowed"); >> + "Non blank after namelist name not allowed"); >> >> if (!is_separator(c) && c != '!') >> { >> >> -- >> You are receiving this mail because: >> You reported the bug. >> > > > -- John Harper, School of Mathematics and Statistics > Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. > e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276 > > -- > You are receiving this mail because: > You reported the bug. > -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #14 from john.harper at vuw dot ac.nz --- Rejecting a semicolon after the namelist name even if the decimal edit mode is COMMA makes sense because COMMA was first allowed in f2003, provided that semicolons in namelist were a pre-f2003 legacy possibility. John H On Sun, 7 May 2023, jvdelisle at gcc dot gnu.org wrote: > Date: Sun, 7 May 2023 18:14:23 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it > Resent-Date: Mon, 8 May 2023 06:14:37 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 > > --- Comment #12 from Jerry DeLisle --- > A additional adjustment to reject the semi-colon always. > > diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c > index 78bfd9e8787..db3330060ce 100644 > --- a/libgfortran/io/list_read.c > +++ b/libgfortran/io/list_read.c > @@ -3598,9 +3598,9 @@ find_nml_name: > > /* A trailing space is required, we allow a comma with std=gnu. */ > c = next_char (dtp); > - if (c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) > + if ((c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) || c == ';') > generate_error (&dtp->common, LIBERROR_READ_VALUE, > - "Comma after namelist name not allowed"); > + "Non blank after namelist name not allowed"); > > if (!is_separator(c) && c != '!') > { > > -- > You are receiving this mail because: > You reported the bug. > -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #13 from Jerry DeLisle --- (In reply to Jerry DeLisle from comment #12) That recent patch regression tests fine. I should mention, there is one of our original test cases in gfortran.dg that does use a comma. We definitely have see the comma used, but I have never seen a semi-colon. I think because it is a newer feature allowing semicoln separators between FORTRAN statements on a single line. (?) Regardless, I am ready to push this out to trunk.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #12 from Jerry DeLisle --- A additional adjustment to reject the semi-colon always. diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 78bfd9e8787..db3330060ce 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -3598,9 +3598,9 @@ find_nml_name: /* A trailing space is required, we allow a comma with std=gnu. */ c = next_char (dtp); - if (c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) + if ((c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) || c == ';') generate_error (&dtp->common, LIBERROR_READ_VALUE, - "Comma after namelist name not allowed"); + "Non blank after namelist name not allowed"); if (!is_separator(c) && c != '!') {
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #11 from john.harper at vuw dot ac.nz --- What about std=2008 ? On Sat, 6 May 2023, jvdelisle at gcc dot gnu.org wrote: > Date: Sat, 6 May 2023 14:45:39 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it > Resent-Date: Sun, 7 May 2023 02:45:51 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 > > Jerry DeLisle changed: > > What|Removed |Added > > Status|NEW |RESOLVED > Resolution|--- |FIXED > > --- Comment #10 from Jerry DeLisle --- > This is fixed on trunk. > > To clarify, the comma is accepted as before with -std=legacy and -std=gnu. > > It is rejected with -std=f95, -std=2003, and -std=f2018. > > Cheers! > > -- > You are receiving this mail because: > You reported the bug. > -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 Jerry DeLisle changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #10 from Jerry DeLisle --- This is fixed on trunk. To clarify, the comma is accepted as before with -std=legacy and -std=gnu. It is rejected with -std=f95, -std=2003, and -std=f2018. Cheers!
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #9 from CVS Commits --- The master branch has been updated by Jerry DeLisle : https://gcc.gnu.org/g:96d699196285858df5d1484b4443cf849908662f commit r14-541-g96d699196285858df5d1484b4443cf849908662f Author: Jerry DeLisle Date: Fri May 5 20:12:25 2023 -0700 Fortran: Namelist read with invalid input accepted. PR fortran/109662 libgfortran/ChangeLog: * io/list_read.c: Add a check for a comma after a namelist name in read input. Issue a runtime error message. gcc/testsuite/ChangeLog: * gfortran.dg/pr109662.f90: New test.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #8 from Jerry DeLisle --- A side comment. We have a runtime function called "notify_std". Every time I try to use it I struggle as it is not intuitively obvious how it works. We ought to provide some better documentation on using it in the gfortran wiki.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #7 from john.harper at vuw dot ac.nz --- I hadn't thought about -std=gnu in this context but it would make sense for std=gnu to give a warning for comma after namelist name if std=legacy is going to allow it without one. You wouldn't then have to change the gfortran manual page. John On Thu, 4 May 2023, John Harper wrote: > Date: Thu, 4 May 2023 16:59:31 +1200 (NZST) > From: John Harper > To: jvdelisle at gcc dot gnu.org > Subject: Re: [Bug libfortran/109662] bad namelist input but gfortran accepted > it > > OK by me but I'm not in charge of gfortran! > > On Thu, 4 May 2023, jvdelisle at gcc dot gnu.org wrote: > >> Date: Thu, 4 May 2023 03:05:49 + >> From: jvdelisle at gcc dot gnu.org >> To: John Harper >> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted >> it >> Resent-Date: Thu, 4 May 2023 15:05:59 +1200 (NZST) >> Resent-From: >> >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 >> >> --- Comment #5 from Jerry DeLisle --- >> Is this acceptable: >> >> $ ./a.out >> Compiler version = GCC version 14.0.0 20230424 (experimental) >> Compiler options = -mtune=generic -march=x86-64 -Wpedantic >> -fpre-include=/usr/include/finclude/math-vector-fortran.h >> At line 9 of file pr109662.f90 >> Fortran runtime error: Comma after namelist name not allowed >> >> Should I allow it with -std=legacy? >> >> -- >> You are receiving this mail because: >> You reported the bug. >> > > > -- John Harper, School of Mathematics and Statistics > Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. > e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276 > -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #6 from john.harper at vuw dot ac.nz --- OK by me but I'm not in charge of gfortran! On Thu, 4 May 2023, jvdelisle at gcc dot gnu.org wrote: > Date: Thu, 4 May 2023 03:05:49 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it > Resent-Date: Thu, 4 May 2023 15:05:59 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 > > --- Comment #5 from Jerry DeLisle --- > Is this acceptable: > > $ ./a.out > Compiler version = GCC version 14.0.0 20230424 (experimental) > Compiler options = -mtune=generic -march=x86-64 -Wpedantic > -fpre-include=/usr/include/finclude/math-vector-fortran.h > At line 9 of file pr109662.f90 > Fortran runtime error: Comma after namelist name not allowed > > Should I allow it with -std=legacy? > > -- > You are receiving this mail because: > You reported the bug. > -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #5 from Jerry DeLisle --- Is this acceptable: $ ./a.out Compiler version = GCC version 14.0.0 20230424 (experimental) Compiler options = -mtune=generic -march=x86-64 -Wpedantic -fpre-include=/usr/include/finclude/math-vector-fortran.h At line 9 of file pr109662.f90 Fortran runtime error: Comma after namelist name not allowed Should I allow it with -std=legacy?
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 --- Comment #4 from Jerry DeLisle --- I knew this looked familiar. We did it on purpose. From list_read.c: /* A trailing space is required, we give a little latitude here, 10.9.1. */ c = next_char (dtp); if (!is_separator(c) && c != '!') { unget_char (dtp, c); goto find_nml_name; } I think we allowed sepraators for some old legacy stuff. I will make adjustments.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 Jerry DeLisle changed: What|Removed |Added CC||jvdelisle at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jvdelisle at gcc dot gnu.org --- Comment #3 from Jerry DeLisle --- I have to say it. We have not seen a NAMELIST bug in a long time. I will take it.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 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 anlauf from comment #1) > I also interpret F2018:13.11.3.1 that a value-separator may follow only > a name-value subsequence but not immediately the namelist-group-name. > This is also what other brands (NAG, Intel, Nvidia) accept. > > Thus confirmed. Yes, definitely a bug. The issue isn't the value-separator. It's item (3) from 13.11.3.1. Input for a namelist input statement consists of (1) optional blanks and namelist comments, (2) the character & followed immediately by the namelist-group-name as specified in the NAMELIST statement, (3) one or more blanks, There needs to be a blank following '&stuff'. Now, the question becomes "what happens with this line?" character(17) :: list = '&stuff , n = 666/' The next requirement comes into play (4) a sequence of zero or more name-value subsequences separated by value separators, and Probably should tag Jerry.
[Bug libfortran/109662] bad namelist input but gfortran accepted it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662 anlauf at gcc dot gnu.org changed: What|Removed |Added Component|fortran |libfortran Last reconfirmed||2023-04-28 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from anlauf at gcc dot gnu.org --- I also interpret F2018:13.11.3.1 that a value-separator may follow only a name-value subsequence but not immediately the namelist-group-name. This is also what other brands (NAG, Intel, Nvidia) accept. Thus confirmed.