Is it a bug?
THOMAS Paul Richard
prthomas@drfccad.cea.fr
Fri Jan 28 13:16:00 GMT 2005
This is a bug that is specific to functions where RESULT is specified in the
function statement(function foo). In this case, the pointer itself is
printed.
Where RESULT is not specified, functions return a pointer result
correctly(function bar). Here the value pointed too is printed.
I will submit this tonight.
$ cat return_pointer.f90
! Test the return of pointer
program ret_ptr
print *, foo (99) , " from function foo (arg) result (ptr)"
print *, bar (99) , " from function bar (arg)"
contains
function foo (arg) result(ptr)
integer :: arg
integer, pointer :: ptr
allocate (ptr)
ptr = arg
end function foo
function bar (arg)
integer :: arg
integer, pointer :: bar
allocate (bar)
bar = arg
end function bar
end program ret_ptr
THOMASP@PC-THOMAS-P /cygdrive/d/gfortran
$ ./a
168034328 from function foo (arg) result (ptr)
99 from function bar (arg)
More information about the Fortran
mailing list