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

--- Comment #11 from janus at gcc dot gnu.org 2011-05-21 20:09:07 UTC ---
(In reply to comment #9)
> program testmv1
> 
>   type bar
>   end type
> 
>   type, extends(bar) ::  bar2
>   end type
> 
>   class(bar), allocatable :: sm
>   type(bar2), allocatable :: sm2
> 
>   allocate(sm2)
>   call move_alloc(sm2,sm)
> 
> end program
> 
> 
> /tmp/ccSfRlZ5.o:(.data+0x38): undefined reference to 
> `__copy_testmv1_Bar2.1582'

The problem here simply is that the vtab is constructed too late (only at
translation stage), so that the __copy routine is never generated. The
following obvious patch fixes it:

Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c    (Revision 174000)
+++ gcc/fortran/check.c    (Arbeitskopie)
@@ -2588,6 +2588,10 @@ gfc_check_move_alloc (gfc_expr *from, gfc_expr *to
       return FAILURE;
     }

+  /* Make sure the vtab is present.  */
+  if (to->ts.type == BT_CLASS)
+    gfc_find_derived_vtab (from->ts.u.derived);
+
   return SUCCESS;
 }

Reply via email to