Fortran Patch for uninitialized variable in gfc_conv_array_parameter

Steve Ellcey sje@cup.hp.com
Fri Jun 1 21:17:00 GMT 2007


I have been getting segfaults from the Fortran compiler when compiling
gfortran.dg/actual_array_constructor_1.f90 and
gfortran.dg/actual_array_constructor_2.f90.  It looks like the problem
is an uninitialized variable.  gfc_conv_array_parameter creates a tree
variable (tmp) and passes the address of it to get_array_ctor_strlen but
get_array_ctor_strlen will dereference and use it (len) before it sets
it so gfc_conv_array_parameter should be initialized before calling
get_array_ctor_strlen.

Should I check this in as obvious?  I tested it quickly but haven't done
a full bootstrap.

Steve Ellcey
sje@cup.hp.com



2007-06-01  Steve Ellcey  <sje@cup.hp.com>

	* trans-array.c (gfc_conv_array_parameter): Initialize tmp.
Index: trans-array.c
===================================================================
--- trans-array.c	(revision 125253)
+++ trans-array.c	(working copy)
@@ -4819,7 +4819,7 @@ gfc_conv_array_parameter (gfc_se * se, g
 {
   tree ptr;
   tree desc;
-  tree tmp;
+  tree tmp = NULL_TREE;
   tree stmt;
   tree parent = DECL_CONTEXT (current_function_decl);
   bool full_array_var, this_array_result;



More information about the Fortran mailing list