public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47778] New: reading two arrays of structures from namelist fails
@ 2011-02-17 10:01 arnold.moene at wur dot nl
  2011-02-17 11:00 ` [Bug fortran/47778] " burnus at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: arnold.moene at wur dot nl @ 2011-02-17 10:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

           Summary: reading two arrays of structures from namelist fails
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arnold.moene@wur.nl


Created attachment 23374
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23374
This code fails

Reading a namelist that contains two variable that are an array of structures
fails. It is not even the assignment that fails, but the parsing already gives
problems.

Attached the code that illustrates the problem.

This may be a follow-up of Bug 42901 (at least it is for me).


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
@ 2011-02-17 11:00 ` burnus at gcc dot gnu.org
  2011-02-17 19:31 ` jvdelisle at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-02-17 11:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |jvdelisle at gcc dot
                   |                            |gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-02-17 10:40:18 UTC ---
At line 27 of file test.f90 (unit = 10, file = '/tmp/gfortrantmp2WKkUW')
Fortran runtime error: Cannot match namelist object name 2

I get the same error with gfortran 4.1.2 20080704 (Red Hat 4.1.2-48)
Thus, it does not seem to be a regression. It works with ifort 11.1, pgf90
10.1-0 and pathscale 3.2.99.

* * *

type field_descr
  integer number
end type
type fsetup
  type (field_descr) :: vel(1)
  type (field_descr) :: scal(1)
end type

&nl_setup"
 field_setup%vel(1)%number=  3,
 field_setup%scal(1)%number=  2 /


For this variant, the error message for the second line of the namelist is some
uninitialized garbage:

At line 23 of file foobar.f90 (unit = 10, file = '/tmp/gfortrantmpMxI6TY')
Fortran runtime error: L�7�


The namelist reading works, if "scal" is a scalar instead of an array.
However, if "vel" is a scalar and "scal" an array, it fails - unless one swaps
the "vel" and "scal" lines in the input file.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
  2011-02-17 11:00 ` [Bug fortran/47778] " burnus at gcc dot gnu.org
@ 2011-02-17 19:31 ` jvdelisle at gcc dot gnu.org
  2011-02-19 16:40 ` jvdelisle at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-17 19:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-17 19:22:31 UTC ---
I will try to look at this one this weekend.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
  2011-02-17 11:00 ` [Bug fortran/47778] " burnus at gcc dot gnu.org
  2011-02-17 19:31 ` jvdelisle at gcc dot gnu.org
@ 2011-02-19 16:40 ` jvdelisle at gcc dot gnu.org
  2011-02-21 14:45 ` jvdelisle at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-19 16:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.02.19 15:52:35
         AssignedTo|unassigned at gcc dot       |jvdelisle at gcc dot
                   |gnu.org                     |gnu.org
     Ever Confirmed|0                           |1

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-19 15:52:35 UTC ---
A reduced test case:

program test_nml
type field_descr
  integer number
end type
type fsetup
  type (field_descr), dimension(3) :: vel
  type (field_descr), dimension(3) :: scal
end type
type (fsetup) field_setup
namelist /nl_setup/ field_setup
field_setup%vel%number = 0
field_setup%scal%number = 0
open(10, status="scratch")
write(10,'(a)') "&nl_setup"
write(10,'(a)') " field_setup%scal(1)%number=  2,"
write(10,'(a)') " field_setup%scal(2)%number=  6,"
write(10,'(a)') "/"
rewind(10)
read(10,nml=nl_setup)
write(*,nml=nl_setup)
end program test_nml


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (2 preceding siblings ...)
  2011-02-19 16:40 ` jvdelisle at gcc dot gnu.org
@ 2011-02-21 14:45 ` jvdelisle at gcc dot gnu.org
  2011-02-27  8:13 ` jvdelisle at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-21 14:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-21 14:35:20 UTC ---
Status update. I have more or less isolated the problem in list-read.c.  I do
not have an exact solution yet, but I am able to get the test case to work. I
just need now to find the right place to make the tweak.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (3 preceding siblings ...)
  2011-02-21 14:45 ` jvdelisle at gcc dot gnu.org
@ 2011-02-27  8:13 ` jvdelisle at gcc dot gnu.org
  2011-02-27 20:10 ` jvdelisle at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-27  8:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-27 07:39:37 UTC ---
Probable Patch, Regression testing:

Index: list_read.c
===================================================================
--- list_read.c    (revision 170492)
+++ list_read.c    (working copy)
@@ -3058,6 +3058,8 @@ find_nml_name:
         goto nml_err_ret;
       generate_error (&dtp->common, LIBERROR_READ_VALUE, nml_err_msg);
         }
+      if (prev_nl && prev_nl->var_rank == 0)
+    prev_nl = NULL;
     }

   free_saved (dtp);


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (4 preceding siblings ...)
  2011-02-27  8:13 ` jvdelisle at gcc dot gnu.org
@ 2011-02-27 20:10 ` jvdelisle at gcc dot gnu.org
  2011-02-27 20:13 ` jvdelisle at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-27 20:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-27 20:06:13 UTC ---
Author: jvdelisle
Date: Sun Feb 27 20:06:10 2011
New Revision: 170548

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170548
Log:
2011-02-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    PR libgfortran/47778
    * io/list_read.c (namelist_read): Intialize the error string buffere.
    If pprev_nl was used during the previous namelist read and the rank
    was zero, reset the pointer to NULL for the next namelist read.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (5 preceding siblings ...)
  2011-02-27 20:10 ` jvdelisle at gcc dot gnu.org
@ 2011-02-27 20:13 ` jvdelisle at gcc dot gnu.org
  2011-02-27 20:16 ` jvdelisle at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-27 20:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-27 20:08:47 UTC ---
Author: jvdelisle
Date: Sun Feb 27 20:08:44 2011
New Revision: 170549

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170549
Log:
2011-02-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    PR libgfortran/47778
    * gfortran.dg/namelist_71.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/namelist_71.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (6 preceding siblings ...)
  2011-02-27 20:13 ` jvdelisle at gcc dot gnu.org
@ 2011-02-27 20:16 ` jvdelisle at gcc dot gnu.org
  2011-03-07  2:06 ` jvdelisle at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-02-27 20:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-02-27 20:10:30 UTC ---
Fixed on trunk.  I will leave this PR open until I get the back ports done.  I
want to give this change a few days on trunk first.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (7 preceding siblings ...)
  2011-02-27 20:16 ` jvdelisle at gcc dot gnu.org
@ 2011-03-07  2:06 ` jvdelisle at gcc dot gnu.org
  2011-03-07  2:12 ` jvdelisle at gcc dot gnu.org
  2011-03-07  2:16 ` jvdelisle at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-07  2:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-07 02:06:32 UTC ---
Author: jvdelisle
Date: Mon Mar  7 02:06:27 2011
New Revision: 170726

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170726
Log:
2011-03-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    PR libgfortran/47778
    * io/list_read.c (namelist_read): Intialize the error string buffere.
    If pprev_nl was used during the previous namelist read and the rank
    was zero, reset the pointer to NULL for the next namelist read.

Modified:
    branches/gcc-4_5-branch/libgfortran/ChangeLog
    branches/gcc-4_5-branch/libgfortran/io/list_read.c


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (8 preceding siblings ...)
  2011-03-07  2:06 ` jvdelisle at gcc dot gnu.org
@ 2011-03-07  2:12 ` jvdelisle at gcc dot gnu.org
  2011-03-07  2:16 ` jvdelisle at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-07  2:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

--- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-07 02:12:01 UTC ---
Author: jvdelisle
Date: Mon Mar  7 02:11:56 2011
New Revision: 170727

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170727
Log:
2011-03-06  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

    Backport from mainline
    PR libgfortran/47778
    * gfortran.dg/namelist_71.f90: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/namelist_71.f90
Modified:
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/47778] reading two arrays of structures from namelist fails
  2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
                   ` (9 preceding siblings ...)
  2011-03-07  2:12 ` jvdelisle at gcc dot gnu.org
@ 2011-03-07  2:16 ` jvdelisle at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2011-03-07  2:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47778

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #11 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2011-03-07 02:16:16 UTC ---
Fixed on 4.5 and 4.6.  Closing


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-03-07  2:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-17 10:01 [Bug fortran/47778] New: reading two arrays of structures from namelist fails arnold.moene at wur dot nl
2011-02-17 11:00 ` [Bug fortran/47778] " burnus at gcc dot gnu.org
2011-02-17 19:31 ` jvdelisle at gcc dot gnu.org
2011-02-19 16:40 ` jvdelisle at gcc dot gnu.org
2011-02-21 14:45 ` jvdelisle at gcc dot gnu.org
2011-02-27  8:13 ` jvdelisle at gcc dot gnu.org
2011-02-27 20:10 ` jvdelisle at gcc dot gnu.org
2011-02-27 20:13 ` jvdelisle at gcc dot gnu.org
2011-02-27 20:16 ` jvdelisle at gcc dot gnu.org
2011-03-07  2:06 ` jvdelisle at gcc dot gnu.org
2011-03-07  2:12 ` jvdelisle at gcc dot gnu.org
2011-03-07  2:16 ` 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).