This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

--- Comment #5 from janus at gcc dot gnu.org 2013-02-09 10:17:16 UTC ---
One can play the same game with scalars, where the situation is even more
severe:

module t

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

contains

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

end module t

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

  call ff(c)
  call f(c)

end program p


The dump shows:

  {
    struct __class_t_Nc class.1;

    class.1._vptr = (struct __vtype_t_Nc * {ref-all}) &__vtab_t_Nc;
    class.1._data = &c;
    ff (&class.1);
  }
  f (&c);

i.e. we set up a polymorphic temporary for the 'ff' call, which we don't do for
'f' since we don't know that it expects a CLASS argument.

Fixing this for the array case would be possible, if we just use the
'polymorphic' version of the array descriptor everywhere.

In the scalar case, we would have to set up a class container, for every call
to a procedure pointer without interface, which is passed a TYPE or CLASS
argument. This would then in turn mean we have to wrap the argument of the
original function 'ff' in a class container, even if it is TYPE. AFAICS, this
could even mean we need an class container (or array descriptor) for *every*
TYPE(t) variable, which would be a rather dramatic change in implementation
(and in principle also affects pure F95 code).

I sincerely hope that all the test cases in this PR are invalud. One should
check the standard!

Btw, do other compilers handle this stuff?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]