This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Procedure Pointers: a first patch
- From: Tobias Burnus <burnus at net-b dot de>
- To: Janus Weil <jaydub66 at googlemail dot com>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Sun, 15 Jun 2008 18:35:53 +0200
- Subject: Re: Procedure Pointers: a first patch
- References: <20080508045757.GA19955@physik.fu-berlin.de> <854832d40805180922t1f2e2a61rb12dbb4d71d809c1@mail.gmail.com> <48308F55.2000108@net-b.de> <854832d40805231349x74c49e45w180b8346e7342e0d@mail.gmail.com> <4837374B.4030304@net-b.de> <483839D9.6000305@net-b.de> <854832d40805241003q6bcf0fdeuc741302eecd1e031@mail.gmail.com> <854832d40805250412r122458bfv981d46687975102f@mail.gmail.com> <854832d40806131203n424c7a49sc130cd64a7a7073@mail.gmail.com> <485429DC.10906@net-b.de> <854832d40806150813r24295d67o6d28258a02785d71@mail.gmail.com>
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