This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/52022] New: [4.5/4.6/4.7 Regression] Wrong-code with procedures passed as actual argument


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]