This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45004] [OOP] Segfault with allocatable scalars and move_alloc
- From: "janus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2010 16:19:41 -0000
- Subject: [Bug fortran/45004] [OOP] Segfault with allocatable scalars and move_alloc
- References: <bug-45004-9410@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from janus at gcc dot gnu dot org 2010-07-23 16:19 -------
Here is a draft patch which deals with allocatable scalars:
Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (revision 162448)
+++ gcc/fortran/trans.c (working copy)
@@ -1157,8 +1157,27 @@ trans_code (gfc_code * code, tree cond)
if (code->resolved_isym
&& code->resolved_isym->id == GFC_ISYM_MVBITS)
is_mvbits = true;
- res = gfc_trans_call (code, is_mvbits, NULL_TREE,
- NULL_TREE, false);
+ if (code->resolved_isym
+ && code->resolved_isym->id == GFC_ISYM_MOVE_ALLOC
+ && code->ext.actual->expr->rank == 0)
+ {
+ gfc_expr *from, *to;
+ stmtblock_t block;
+ tree tmp;
+
+ from = code->ext.actual->expr;
+ to = code->ext.actual->next->expr;
+
+ gfc_start_block (&block);
+ tmp = gfc_trans_pointer_assignment (to, from);
+ gfc_add_expr_to_block (&block, tmp);
+ tmp = gfc_trans_pointer_assignment (from, gfc_get_null_expr
(NULL));
+ gfc_add_expr_to_block (&block, tmp);
+ res = gfc_finish_block (&block);
+ }
+ else
+ res = gfc_trans_call (code, is_mvbits, NULL_TREE,
+ NULL_TREE, false);
}
break;
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |janus at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2010-07-22 21:21:57 |2010-07-23 16:19:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45004