public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52022] New: [4.5/4.6/4.7 Regression] Wrong-code with procedures passed as actual argument
@ 2012-01-27 17:54 burnus at gcc dot gnu.org
  2012-01-27 18:05 ` [Bug fortran/52022] " burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-01-27 17:54 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-01-28 11:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-27 17:54 [Bug fortran/52022] New: [4.5/4.6/4.7 Regression] Wrong-code with procedures passed as actual argument burnus at gcc dot gnu.org
2012-01-27 18:05 ` [Bug fortran/52022] " burnus at gcc dot gnu.org
2012-01-27 20:43 ` burnus at gcc dot gnu.org
2012-01-27 21:07 ` jakub at gcc dot gnu.org
2012-01-28 11:00 ` burnus at gcc dot gnu.org
2012-01-28 11:41 ` burnus at gcc dot gnu.org
2012-01-28 11:55 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).