This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, Fortran, pr79335, v2] [7 Regression] Conditional jump or move depends on uninitialised in value get_scalar_to_descriptor_type(tree_node*, symbol_attribute) (trans-expr.c:53)


Hi all,

attached patch fixes (hopefully) all occurrences of uninitialized
symbol_attributes used for getting a descriptor for a scalar as reported in the
reopended pr79335.

Bootstraps and regtests ok on x86_64-linux/f25. Ok for trunk?

Regards,
	Andre

On Tue, 14 Feb 2017 08:32:59 +0000
"marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79335
> 
> Martin Liška <marxin at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|WAITING                     |REOPENED
> 
> --- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
> Thanks for fix, however there are still some issues:
> 
> $ valgrind --leak-check=yes --trace-children=yes ./xgcc -B.
> /home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/coarray_lib_alloc_4.f90
> -fcoarray=lib -lcaf_single 
> 
> ==15334== Conditional jump or move depends on uninitialised value(s)
> ==15334==    at 0x95EE91: get_scalar_to_descriptor_type(tree_node*,
> symbol_attribute) (trans-expr.c:53)
> ==15334==    by 0x95EFF0: gfc_conv_scalar_to_descriptor(gfc_se*, tree_node*,
> symbol_attribute) (trans-expr.c:71)
> ==15334==    by 0x977D9C: gfc_trans_structure_assign(tree_node*, gfc_expr*,
> bool, bool) (trans-expr.c:7552)
> ==15334==    by 0x97830F: gfc_conv_structure(gfc_se*, gfc_expr*, int)
> (trans-expr.c:7646)
> ==15334==    by 0x978AD9: gfc_conv_expr(gfc_se*, gfc_expr*)
> (trans-expr.c:7813) ==15334==    by 0x97F5EC:
> gfc_trans_assignment_1(gfc_expr*, gfc_expr*, bool, bool, bool, bool)
> (trans-expr.c:9923) ==15334==    by 0x9804A5: gfc_trans_assignment(gfc_expr*,
> gfc_expr*, bool, bool, bool, bool) (trans-expr.c:10231)
> ==15334==    by 0x9804E1: gfc_trans_init_assign(gfc_code*)
> (trans-expr.c:10237) ==15334==    by 0x9D2655: gfc_trans_allocate(gfc_code*)
> (trans-stmt.c:6328) ==15334==    by 0x92077B: trans_code(gfc_code*,
> tree_node*) (trans.c:1965) ==15334==    by 0x9209F6:
> gfc_trans_code(gfc_code*) (trans.c:2124) ==15334==    by 0x95B503:
> gfc_generate_function_code(gfc_namespace*) (trans-decl.c:6306)
> ...
> 


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 

Attachment: pr79335_v2.clog
Description: Text document

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index d0dfc26..47e8c09 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -7950,6 +7950,8 @@ duplicate_allocatable_coarray (tree dest, tree dest_tok, tree src,
       tree dummy_desc;
 
       gfc_init_se (&se, NULL);
+      gfc_clear_attr (&attr);
+      attr.allocatable = 1;
       dummy_desc = gfc_conv_scalar_to_descriptor (&se, dest, attr);
       gfc_add_block_to_block (&globalblock, &se.pre);
       size = TYPE_SIZE_UNIT (TREE_TYPE (type));
@@ -8518,14 +8520,15 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
 	      else
 		{
 		  gfc_se se;
-		  symbol_attribute attr;
 
 		  gfc_init_se (&se, NULL);
-		  gfc_clear_attr (&attr);
 		  token = fold_build3_loc (input_location, COMPONENT_REF,
 					   pvoid_type_node, decl, c->caf_token,
 					   NULL_TREE);
-		  comp = gfc_conv_scalar_to_descriptor (&se, comp, attr);
+		  comp = gfc_conv_scalar_to_descriptor (&se, comp,
+							c->ts.type == BT_CLASS
+							? CLASS_DATA (c)->attr
+							: c->attr);
 		  gfc_add_block_to_block (&fnblock, &se.pre);
 		}
 
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 87bf069..cc41fe3 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -7516,7 +7516,6 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr, bool init, bool coarray)
 	  && (!c->expr || c->expr->expr_type == EXPR_NULL))
 	{
 	  tree token, desc, size;
-	  symbol_attribute attr;
 	  bool is_array = cm->ts.type == BT_CLASS
 	      ? CLASS_DATA (cm)->attr.dimension : cm->attr.dimension;
 
@@ -7549,7 +7548,10 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr, bool init, bool coarray)
 	    }
 	  else
 	    {
-	      desc = gfc_conv_scalar_to_descriptor (&se, field, attr);
+	      desc = gfc_conv_scalar_to_descriptor (&se, field,
+						    cm->ts.type == BT_CLASS
+						    ? CLASS_DATA (cm)->attr
+						    : cm->attr);
 	      size = TYPE_SIZE_UNIT (TREE_TYPE (field));
 	    }
 	  gfc_add_block_to_block (&block, &se.pre);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]