[patch, libgfortran] PR47778 reading two arrays of structures from namelist fails

Jerry DeLisle jvdelisle@frontier.com
Sun Feb 27 18:02:00 GMT 2011


Hi all,

The attached patch fixes this bug by resetting the pprev_nl pointer to NULL when 
the rank of the previous object read was zero.  pprev_nl is used to track 
multiple reads from the same namelist variable.

Regression tested on x86-64.

OK for trunk?  I suggest we should back port to 4.5 and possibly earlier.

Regards,

Jerry

2011-02-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/47778
	* io/list_read.c (namelist_read): 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.


Index: io/list_read.c
===================================================================
--- io/list_read.c	(revision 170543)
+++ io/list_read.c	(working copy)
@@ -3058,6 +3058,8 @@
  	    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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: namelist_71.f90
Type: text/x-fortran
Size: 1212 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110227/52dd187c/attachment.bin>


More information about the Gcc-patches mailing list