From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20894 invoked by alias); 9 Feb 2013 10:08:39 -0000 Received: (qmail 20781 invoked by uid 48); 9 Feb 2013 10:08:25 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/56261] [OOP] seg fault call procedure pointer on polymorphic array Date: Sat, 09 Feb 2013 10:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg00895.txt.bz2 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); }