[Fortran] Coarrays: Don't (free)/alloc LHS coarray components on assignment

Message ID 51E5B3D8.9020107@net-b.de
State New
Headers show

Commit Message

Tobias Burnus July 16, 2013, 8:58 p.m.
Tejas Belagod wrote:
> I observed that this patch causes an ICE with one of the fortran 
> tests. I've filed a bug report here: 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57912.

Thanks for the report! For some reason, the following bit from my local 
tree didn't end up in the patch. Committed as Rev. 200987.


PS: Your backtrace in the PR looks odd; I get the following (also on 
x86-64-gnu-linux), which is much more reasonable. I wonder why yours is off.

0x5fb0ee gfc_trans_scalar_assign(gfc_se*, gfc_se*, gfc_typespec, bool, 
bool, bool)
0x606e62 gfc_trans_assignment_1
0x5cb565 trans_code
0x5f434e gfc_generate_function_code(gfc_namespace*)
0x5ccef1 gfc_generate_module_code(gfc_namespace*)
0x58b147 translate_all_program_units
0x58b147 gfc_parse_file()
0x5c7205 gfc_be_parse_file


Index: gcc/fortran/ChangeLog
--- gcc/fortran/ChangeLog	(Revision 200986)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,9 @@ 
+2013-07-16  Tobias Burnus  <burnus@net-b.de>
+	PR fortran/57912
+	* trans-expr.c (gfc_trans_scalar_assign): Correct if
+	condition for caf realloc.
 2013-07-15  Tobias Burnus  <burnus@net-b.de>
 	* trans-array.h (gfc_deallocate_alloc_comp_no_caf,
Index: gcc/fortran/trans-expr.c
--- gcc/fortran/trans-expr.c	(Revision 200986)
+++ gcc/fortran/trans-expr.c	(Arbeitskopie)
@@ -6857,9 +6857,8 @@  gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rs
 			   fold_convert (TREE_TYPE (lse->expr), rse->expr));
       /* Restore pointer address of coarray components.  */
-      if (ts.u.derived->attr.coarray_comp && deep_copy)
+      if (ts.u.derived->attr.coarray_comp && deep_copy && tmp_var != NULL_TREE)
-	  gcc_assert (tmp_var != NULL_TREE);
 	  tmp = gfc_reassign_alloc_comp_caf (ts.u.derived, tmp_var, lse->expr);
 	  tmp = build3_v (COND_EXPR, cond, build_empty_stmt (input_location),