http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55978
--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2013-01-14
23:03:04 UTC ---
A reduced test case which shows the problem in the dump:
! { dg-do run }
! { dg-options "-fcoarray=single" }
!
! PR fortran/50981
! PR fortran/54618
!
program main
implicit none
type t
integer, allocatable :: i
end type t
type, extends (t):: t2
integer, allocatable :: j
end type t2
call a3a()
contains
subroutine a3a(z, z2, z3)
type(t2), optional :: z(4)
type(t2), optional, pointer :: z2(:)
type(t2), optional, allocatable :: z3(:)
type(t2), allocatable :: x(:)
type(t2), pointer :: y(:)
y => null()
call a4t2(y)
end subroutine a3a
subroutine a4t2(x)
type(t2), intent(in), optional :: x(4)
if (present (x)) call abort ()
!print *, present(x)
end subroutine a4t2
end program
ig25@linux-fd1f:~/Krempel/Os> gfortran -fcoarray=single -fdump-tree-original
c.f90
ig25@linux-fd1f:~/Krempel/Os> cat c.f90.003t.original
a4t2 (struct t2[4] * restrict x)
{
if (x != 0B)
{
_gfortran_abort ();
}
L.1:;
}
a3a (struct t2[4] * restrict z, struct array1_t2 * z2, struct array1_t2 * z3)
{
struct array1_t2 y;
y.data = 0B;
y.data = 0B;
{
void * D.1914;
D.1914 = _gfortran_internal_pack (&y);
a4t2 (D.1914);
if ((struct t2[0:] *) y.data != (struct t2[0:] *) D.1914)
{
{
void * D.1915;
D.1915 = D.1914;
if (D.1915 != 0B)
{
__builtin_free (D.1915);
}
}
}
}
}
_gfortran_internal_pack is called without setting up the array descriptor.