[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2024-04-09 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

Jerry DeLisle  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from Jerry DeLisle  ---
Fixed on trunk. Closing.

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2024-02-17 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #9 from GCC Commits  ---
The master branch has been updated by Jerry DeLisle :

https://gcc.gnu.org/g:fccfe6625121512f247cb59888e50eb9dcc84409

commit r14-9048-gfccfe6625121512f247cb59888e50eb9dcc84409
Author: Jerry DeLisle 
Date:   Fri Feb 16 17:06:37 2024 -0800

libgfortran: Fix namelist read.

PR libfortran/107068

libgfortran/ChangeLog:

* io/list_read.c (read_logical): When looking for a possible
variable name, check for left paren, indicating a possible
array reference.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr107068.f90: New test.

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2024-02-16 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #8 from Jerry DeLisle  ---
After a bit of sleuthing it turns out that the '(' in the name was being
ignored and the comma in '(1,2)' was being treated as a delimiter.  Since the
following '=' was not seen yet, the 2 was seen as a repeat value and we get the
error.

This is fixed with the following patch:

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index f8ca64422de..0b7884fdda7 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -888,6 +888,14 @@ read_logical (st_parameter_dt *dtp, int length)
   for(i = 0; i < 63; i++)
 {
   c = next_char (dtp);
+  if (c == '(')
+   {
+ l_push_char (dtp, c);
+ dtp->u.p.nml_read_error = 1;
+ dtp->u.p.line_buffer_enabled = 1;
+ dtp->u.p.line_buffer_pos = 0;
+ return;
+   }
   if (is_separator(c))
{
  /* All done if this is not a namelist read.  */

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2023-05-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #7 from Jerry DeLisle  ---
In list_read.c we have this comment:

/* To read a logical we have to look ahead in the input stream to make sure
there is not an equal sign indicating a variable name.  To do this we use
line_buffer to point to a temporary buffer, pushing characters there for
possible later reading. */

I remember creating this line_buffer for the purpose. Now to figure out why it
is not working. This was quite a while ago!

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2023-05-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #6 from Jerry DeLisle  ---
What is happening here is that in the name list input, the variable flp is also
a legal LOGICAL value, so our read is interpreting it as the second value of
the array flc and trying to continue to read values for flc. It encounters the
( and throws the error.

To resolve this, I think I will have to check for a valid variable name for
each value.

[aside: A lot of these issues stem from the weaknesses in how namelists are
interpreted.  There are ambiguities in the specification.]

My next step here is to go through the F2018 standard just to make sure what we
do is valid or invalid. (cheers)

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2023-05-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

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 #5 from Jerry DeLisle  ---
I will get looking at this since it is namelist related.

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2022-09-28 Thread r.m.potvliege at durham dot ac.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #4 from Robert Potvliege  ---
Thanks for looking into this so quickly and for the work-round.

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2022-09-28 Thread r.m.potvliege at durham dot ac.uk via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #3 from Robert Potvliege  ---
Thanks for looking into this so quickly and for the work-round.

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2022-09-28 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
  Component|fortran |libfortran
   Last reconfirmed||2022-09-28

--- Comment #2 from anlauf at gcc dot gnu.org ---
Confirmed.

Renaming the second variable (e.g. flp -> xlp) works around the problem,
as well as interchanging the lines in the namelist input.

It appears that while scanning the namelist input we first see the T,
then F, for which we try to determine if it means .false. or is part of
a variable name, and then possibly screw up because we see a comma when
referring to an element of rank-2 array flp.

There is also no error when using a rank-1 array for flp and referring
to flp(2) etc.