The following code fail with message:
Error: Parameter 'sub1' to 'c_funloc' at (1) must be BIND(C)
It works with g95 and with ifort

code:
   use, intrinsic :: iso_c_binding
   interface
      real function sub2(a,b)
         real,intent(in) :: a, b
      end function sub2
   end interface
   procedure(sub2), pointer :: sub2_pt
   type(c_funptr) :: sub3_pt
   external sub1
   real :: sum
!
   sub3_pt=c_funloc(sub1)
!
   call c_f_procpointer(sub3_pt, sub2_pt)
   sum=sub2_pt(5.,7.)
   print *,'a+b=',sum
   stop
end program main
!
real function sub1(a,b)
   real :: a, b
   sub1=a+b
   return
end function sub1


-- 
           Summary: bug with procedure pointers and C interoperability
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alain dot hebert at polymtl dot ca


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40354

Reply via email to