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]

Re: Procedure Pointers: a first patch


Hi Janus,

Janus Weil wrote:
the attached update of the patch should handle NULL and ASSOCIATED now
Well, NULL() still does not work. As an example counts more than thousand descriptions, here comes one which works with g95 and ifort 11beta but fails with gfortran. The problem is that the line

void (*<T5f>) (void) x;

should be

static void (*<T5f>) (void) x = 0B;

program main
implicit none
call test(.true.)
call test(.false.)

contains
integer function hello()
 print *, 'Hello'
 hello = 42
end function hello
subroutine test(first)
 logical :: first
 integer :: i
 procedure(), pointer :: x => null()

 if(first) then
   if(associated(x)) call abort()
   x => hello
 else
   if(.not. associated(x)) call abort()
   i = hello()
   if(i /= 42) call abort()
 end if
 end subroutine test
end program main


subroutine s_out(p)
PROCEDURE(REAL),POINTER,INTENT(OUT) :: p
intrinsic abs
p => abs
end subroutine
The error message has been cured, but it still produces a segfault at
runtime (see proc_ptr_5.f90)
Well, the problem is that the procedure pointer is passed as value and not as reference.
See http://gcc.gnu.org/ml/fortran/2008-05/msg00299.html



I think the patch can be committed after: - NULL() is fixed - Procedure pointers are passed by reference

Working procedure-pointer-returning functions were nice, but I think they can be deferred to a follow up patch. The same is true for the other smaller bugs.

Tobias


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