From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6145 invoked by alias); 27 Jan 2012 17:07:36 -0000 Received: (qmail 5933 invoked by uid 22791); 27 Jan 2012 17:07:31 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Fri, 27 Jan 2012 17:07:17 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52022] New: [4.5/4.6/4.7 Regression] Wrong-code with procedures passed as actual argument Date: Fri, 27 Jan 2012 17:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: burnus 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: 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: 2012-01/txt/msg03181.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52022 Bug #: 52022 Summary: [4.5/4.6/4.7 Regression] Wrong-code with procedures passed as actual argument Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org Reported by patnel97269 at http://gcc.gnu.org/ml/fortran/2012-01/msg00232.html The following program - a stripped-down version of the original version - compiles and successfully runs with GCC 4.3 and 4.4. It prints: 2.0000000000000000 4.0000000000000000 Using GCC 4.5, 4.6 and 4.7, one gets instead a SEGFAULT. In 4.4, the passed argument is: sol (cost1); while 4.5/4.6/4.7 pass the argument: sol (&cost1); which does not make much sense. There might be internally some confusion between procedures dummies (pass address of procedure to be called) and procedures pointers (pass address of the callee such that it can be assigned to). module m contains function cost1(x) result(y) double precision,dimension(:) :: x double precision,dimension(:),allocatable :: y allocate(y(2)) y=2d0*x end function cost1 end module m program test use m implicit none call sol(cost1) contains subroutine sol(cost3) interface function cost3(p) result(y) double precision,dimension(:) :: p double precision,dimension(:),allocatable :: y end function cost3 end interface print *,cost3([1d0,2d0]) end subroutine end program test