diff mbox

[libgfortran] PR 46010 - I/O: Namelist-reading bug

Message ID 4CC621FF.3010103@frontier.com
State New
Headers show

Commit Message

Jerry DeLisle Oct. 26, 2010, 12:34 a.m. UTC
Hi all,

The attached patch is simple and fairly safe.  It adds a couple of conditions to 
assure that nml_parse_qualifier sets the end index for the loop spec.  I will 
add the two test cases in the PR to our testsuite.

Regression tested on x86-64.  OK for trunk?

Jerry

2010-10-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/46010
	* io/list_read.c (nml_parse_qualifier): Add additional conditions for
	setting the end index for loop specification. Fix some whitespace.
diff mbox

Patch

Index: list_read.c
===================================================================
--- list_read.c	(revision 165900)
+++ list_read.c	(working copy)
@@ -2105,8 +2105,10 @@  nml_parse_qualifier (st_parameter_dt *dtp, descrip
 
 		  /*  If -std=f95/2003 or an array section is specified,
 		      do not allow excess data to be processed.  */
-                  if (is_array_section == 1
-		      || !(compile_options.allow_std & GFC_STD_GNU))
+		  if (is_array_section == 1
+		      || !(compile_options.allow_std & GFC_STD_GNU)
+		      || !dtp->u.p.ionml->touched
+		      || dtp->u.p.ionml->type == BT_DERIVED)
 		    ls[dim].end = ls[dim].start;
 		  else
 		    dtp->u.p.expanded_read = 1;
@@ -2121,12 +2123,12 @@  nml_parse_qualifier (st_parameter_dt *dtp, descrip
 	}
 
       if (is_array_section == 1 && dtp->u.p.expanded_read == 1)
-     	{
+	{
 	  int i;
 	  dtp->u.p.expanded_read = 0;
 	  for (i = 0; i < dim; i++)
 	    ls[i].end = ls[i].start;
-      	}
+	}
 
       /* Check the values of the triplet indices.  */
       if ((ls[dim].start > (ssize_t) GFC_DIMENSION_UBOUND(ad[dim]))
Index: write.c
===================================================================
--- write.c	(revision 165900)
+++ write.c	(working copy)
@@ -65,7 +65,7 @@  memcpy4 (gfc_char4_t *dest, const char *source, in
 /* Write out default char4.  */
 
 static void
-write_default_char4 (st_parameter_dt *dtp, gfc_char4_t *source,
+write_default_char4 (st_parameter_dt *dtp, const gfc_char4_t *source,
 		     int src_len, int w_len)
 {
   char *p;