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



--- Comment #13 from janus at gcc dot gnu.org 2012-10-14 16:31:31 UTC ---

Transferring CLASS to TYPE has been discussed in comment 9 and 10. Now: TYPE to

CLASS ...



Here the test case gets a bit larger, since gfortran does not yet support

intrinsic assignment to polymorphic variables (PR 43366), so we need a defined

assignment procedure:



module m

  implicit none

  type test_type

    integer :: i

  contains

    procedure :: ass

    generic :: assignment(=) => ass

  end type

contains

  subroutine ass (a, b)

    class(test_type), intent(out) :: a

    class(test_type), intent(in)  :: b

    a%i = b%i

  end subroutine

end module



program p

  use m

  implicit none



  class(test_type), allocatable :: c

  type(test_type) :: t



  t%i=3

  allocate(c)

  c = transfer(t, c)

  print *,c%i

end





With ifort, the expected output ("3") is produced. sunf95 refuses to compile it

(doesn't like type-bound procedures). gfortran compiles it, but produces a

segfault at runtime. The dump looks like this:



{

  struct __class_m_Test_type_a D.1895;

  struct __class_m_Test_type_a transfer.0;

  integer(kind=8) D.1893;

  integer(kind=8) D.1892;

  integer(kind=8) D.1891;



  D.1891 = 4;

  D.1892 = 16;

  __builtin_memcpy ((void *) &transfer.0, (void *) &t, MAX_EXPR <MIN_EXPR

<D.1892, D.1891>, 0>);

  D.1895 = transfer.0;

  ass (&c, &D.1895);

}



So, again, _data and _size references missing.

Reply via email to