From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27404 invoked by alias); 11 Jan 2011 21:39:08 -0000 Received: (qmail 27395 invoked by uid 22791); 11 Jan 2011 21:39:07 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_TM X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Jan 2011 21:39:02 +0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47240] [F03] segfault with procedure pointer component 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: dominiq at lps dot ens.fr X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: janus 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 Date: Tue, 11 Jan 2011 23:15:00 -0000 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: 2011-01/txt/msg01118.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47240 --- Comment #8 from Dominique d'Humieres 2011-01-11 21:38:46 UTC --- (In reply to comment #7) > > ... > > ... this produces loads of regressions. > > ... but the following variant doesn't: > ... Confirmed, however the following code [macbook] f90/bug% cat pr35971_red.f90 module other_fun use ISO_C_BINDING implicit none private ! Message to be returned by procedure pointed to ! by the C_FUNPTR character, allocatable, save :: my_message(:) ! Interface block for the procedure pointed to ! by the C_FUNPTR public abstract_fun abstract interface function abstract_fun(x) use ISO_C_BINDING import my_message implicit none integer(C_INT) x(:) character(size(my_message),C_CHAR) abstract_fun(size(x)) end function abstract_fun end interface contains ! Procedure to store the message and get the C_FUNPTR function gp(message) bind(C,name='BlAh') ! procedure(abstract_fun) make_mess character(kind=C_CHAR) message(*) type(C_FUNPTR) gp integer(C_INT64_T) i i = 1 do while(message(i) /= C_NULL_CHAR) i = i+1 end do my_message = message(int(1,kind(i)):i-1) gp = get_funloc(make_mess,aux) ! gp = aux(make_mess) end function gp ! Intermediate procedure to pass the function and get ! back the C_FUNPTR function get_funloc(x,y) procedure(abstract_fun) x type(C_FUNPTR) y external y type(C_FUNPTR) get_funloc get_funloc = y(x) end function get_funloc ! Procedure to convert the function to C_FUNPTR function aux(x) interface subroutine x() bind(C) end subroutine x end interface type(C_FUNPTR) aux aux = C_FUNLOC(x) end function aux ! Procedure pointed to by the C_FUNPTR function make_mess(x) integer(C_INT) x(:) character(size(my_message),C_CHAR) make_mess(size(x)) make_mess = transfer(my_message,make_mess(1)) end function make_mess end module other_fun end gives at -O2 and above [macbook] f90/bug% gfc -O2 pr35971_red.f90 pr35971_red.f90: In function 'gp': pr35971_red.f90:67:0: error: non-trivial conversion at assignment void (*) (void) void (*) (struct array1_unknown &, integer(kind=4), struct array1_integer(kind=4) & restrict) __result_gp_72 = make_mess; pr35971_red.f90:67:0: internal compiler error: verify_stmts failed