From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 08893385DC22; Fri, 28 May 2021 13:34:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08893385DC22 From: "mailling-lists-bd at posteo dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100813] New: Function of array of pointers to abstract class returning an array Date: Fri, 28 May 2021 13:34:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mailling-lists-bd at posteo dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 May 2021 13:34:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100813 Bug ID: 100813 Summary: Function of array of pointers to abstract class returning an array Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mailling-lists-bd at posteo dot de Target Milestone: --- Hello,=20 I was trying to write a function that takes an array of pointers to an abst= ract class as argument, and that returns an array with a shape determined by a member of the mentioned abstract class. The following example segfaults wi= th gfortran 10.3 on Opensuse:=20 module baseClass implicit none type, abstract, public :: base integer, allocatable :: i(:) contains procedure(sub), deferred, pass :: mysub end type base abstract interface subroutine sub(bb)=20 import :: base class(base), intent(in) :: bb end subroutine sub end interface type, public :: baseWrap class(base), pointer :: p end type baseWrap public :: operate_on_baseWrap contains function operate_on_baseWrap(wrapped) result(res) class(baseWrap), intent(in) :: wrapped(:) integer :: i, tmp integer, dimension(size(wrapped(1)%p%i)) :: res do i=3D1, size(wrapped) call wrapped(i)%p%mysub end do res =3D 0 end function operate_on_baseWrap end module baseClass module childClass use baseClass implicit none type, extends(base), public :: child1 contains procedure, pass :: mysub =3D> sub_child1 end type child1 contains subroutine sub_child1(bb) class(child1), intent(in) :: bb print *, 'Do something', bb%i end subroutine sub_child1 end module childClass program test use baseClass use childClass implicit none type(baseWrap), allocatable :: wrapper(:) type(child1), allocatable, target :: c(:) integer :: i integer, allocatable :: tmp(:) allocate(wrapper(3)) allocate(c(3)) do i=3D1, 3 allocate(c(i)%i(3)) c(i)%i =3D i wrapper(i)%p =3D> c(i) end do allocate(tmp(size(wrapper(1)%p%i))) tmp =3D operate_on_baseWrap(wrapper) end program test=