This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Problem with Procedure Pointers
- From: Robert Rosenberg <robert dot rosenberg at nrl dot navy dot mil>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 3 Jun 2014 11:03:43 -0400
- Subject: Problem with Procedure Pointers
- Authentication-results: sourceware.org; auth=none
I was writing some sample code that defines a function that returns a pointer procedure.
When I compile the code with Intel Ifort.14.x/15.x it complains saying that this exact feature is not supported.
When I compile with GNU gfortran49, it compiles and runs fine. But when I insert the statement, 'implicit none' at the beginning of the code, the code fails to compile. If I then use an implicit procedure pointer interface, it again runs fine.
Does anybody know if gfortan49 is _suppose_ to support the ability to define functions that return a procedure pointer?
I include the code below:
! fails to compile under gfortran49
! change: implict none -> !implict none works fine
! change: procedure(rfunction) -> procedure() works fine
module test
implicit none
private
abstract interface
real function rfunction(a)
real, intent (in) :: a
end function rfunction
end interface
type functions
private
procedure (rfunction), pointer, nopass :: pf => NULL()
contains
procedure :: get_pf
end type
contains
function get_pf(f)
class (functions) :: f
procedure (rfunction), pointer :: get_pf
get_pf => f%pf
end function
end module