This is the mail archive of the gcc-bugs@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]

[Bug fortran/41714] [OOP] ALLOCATE SOURCE= does not properly copy the value from SOURCE



------- Comment #1 from janus at gcc dot gnu dot org  2009-10-15 13:14 -------
Certainly mine. I should have thought of this case when fixing PR41581. The
cure is for sure:

Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c    (Revision 152720)
+++ gcc/fortran/trans-stmt.c    (Arbeitskopie)
@@ -4091,6 +4091,18 @@ gfc_trans_allocate (gfc_code * code)
              gfc_free_expr (sz);
              tmp = gfc_build_memcpy_call (dst.expr, src.expr, len.expr);
            }
+         else if (al->expr->ts.type == BT_CLASS
+                  && rhs->ts.u.derived != expr->ts.u.derived)
+           {
+             gfc_se dst,src;
+             gfc_init_se (&dst, NULL);
+             gfc_init_se (&src, NULL);
+             gfc_conv_expr (&dst, expr);
+             gfc_conv_expr (&src, rhs);
+             gfc_add_block_to_block (&block, &src.pre);
+             tmp = TYPE_SIZE_UNIT (gfc_typenode_for_spec (&rhs->ts));
+             tmp = gfc_build_memcpy_call (dst.expr, src.expr, tmp);
+           }
          else
            tmp = gfc_trans_assignment (gfc_expr_to_initialize (expr),
                                        rhs, false);


-- 

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|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-10-15 13:14:36
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41714


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