[Bug fortran/54917] [4.7/4.8 Regression] [OOP] TRANSFER on polymorphic variable causes ICE

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Oct 14 11:15:00 GMT 2012


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

--- Comment #9 from janus at gcc dot gnu.org 2012-10-14 11:15:25 UTC ---
Ok, after the ICEs are fixed, let's come to runtime behavior. Here is a test
case:

  implicit none
  type test_type
    integer :: i
  end type
  class(test_type), allocatable :: c
  type(test_type) :: t

  allocate(c)
  c%i=3
  t = transfer(c, t)
  print *,t

end


With ifort and sunf95 this gives the expected output of "3", while gfortran
just spits out random numbers. -fdump-tree-original shows the following:

{
  struct test_type transfer.0;
  integer(kind=8) D.1884;
  integer(kind=8) D.1883;
  integer(kind=8) D.1882;

  D.1882 = 16;
  D.1883 = 4;
  __builtin_memcpy ((void *) &transfer.0, (void *) &c, MAX_EXPR <MIN_EXPR
<D.1883, D.1882>, 0>);
  t = transfer.0;
}

Clearly, the "&c" here should be "&c._data".



More information about the Gcc-bugs mailing list