https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105168

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org

--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 60039
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60039&action=edit
Partial fix for this PR

The attached fixes the original testcase.

The first chunk gets rid of the segfault since it passes a class container to
'f', rather than the array descriptor.

The second chunk resets the temporary descriptor lbounds to one, adjusts the
ubounds accordingly and sets the offset.

The first chunk in gfc_trans_arrayfunc_assign is required for the variant at
the bottom of this comment, which segfaults even without braces around 'y'.

If the component of 't' is made allocatable, a load of invalid reads and use of
uninitialised value errors appear. I am working on this.

Paul

! Interface mapping is failing with CLASS 'x' and parentheses around
! the actual argument.
module m
   type t
      integer :: a
   contains
      final :: final_t
   end type
   integer :: cntr = 0
contains
   function f(x) result(z)
      class(t) :: x(:) ! Worked, with or without parentheses if s/CLASS/TYPE/
      type(t) :: z(2)
      z = x
   end
   subroutine final_t (arg)
      type (t) :: arg
      cntr = cntr + 1
   end subroutine
end module
program p
   use m
   class(t), allocatable :: y(:), z(:)
   y = [t(2),t(4)]
   allocate (t :: z(2))
   call foo
   print *, z(1)%a
   deallocate (y, z)
   print *, cntr
contains
   subroutine foo
      z = f((y))          ! Failed even with parentheses removed
   end
end

Reply via email to