This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Problem with Procedure Pointers


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

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