[Bug fortran/56261] [OOP] seg fault call procedure pointer on polymorphic array

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Feb 9 10:08:00 GMT 2013


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

--- Comment #4 from janus at gcc dot gnu.org 2013-02-09 10:08:23 UTC ---
Actually I wonder whether the test case is really valid. The problem is: When
declaring the procedure pointer without an interface, we don't know which kind
of argument it expects. Here is a slightly modified variant:

module t

  type :: nc
     integer :: n = 1
  end type nc

contains

  subroutine ff(self)
    implicit none
    class(nc), intent(in), dimension(:) :: self
    write (0,*) '  --> content of self(1)%n) is ',self(1)%n
  end subroutine

end module t

program p
  use t
  implicit none
  type    (nc), dimension(1:10) :: c
  procedure(), pointer                   :: f => ff

  call ff(c)
  call f(c)

end program p


As the dump shows, we set up a different array descriptor for both cases, since
we don't know that the procedure pointer expects a polymorphic argument:

  {
    struct array1_nc parm.2;
    struct __class_t_Nc_1_0 class.1;

    class.1._vptr = (struct __vtype_t_Nc * {ref-all}) &__vtab_t_Nc;
    parm.2.dtype = 297;
    parm.2.dim[0].lbound = 1;
    parm.2.dim[0].ubound = 10;
    parm.2.dim[0].stride = 1;
    parm.2.data = (void *) &c[0];
    parm.2.offset = -1;
    class.1._data = parm.2;
    ff (&class.1);
  }
  {
    struct array1_nc parm.3;

    parm.3.dtype = 297;
    parm.3.dim[0].lbound = 1;
    parm.3.dim[0].ubound = 10;
    parm.3.dim[0].stride = 1;
    parm.3.data = (void *) &c[0];
    parm.3.offset = -1;
    f ((struct nc[0:] *) parm.3.data);
  }



More information about the Gcc-bugs mailing list