language lawyer question
Paul Thomas
paulthomas2@wanadoo.fr
Fri Jan 21 06:10:00 GMT 2005
The problem lies in this function:
function getOa(ob) result(oa)
type(objB),target :: ob
type(objA), pointer :: oa
oa=>ob%oa
end function getOa
You return a pointer to a derived type component that is declared within the
scope of the ultimate caller. I think, therefore that it is legal fortran
because the returned pointer is pointing to allocated memory.
There are various PR's on passing character pointer arguments:
15809/17207/18991/16939. I think that this is the first involving derived
types?
The program works correctly with
function getOa(ob) result(oa)
type(objB),target :: ob
type(objA) :: oa !no longer a pointer
oa=ob%oa !normal assignment
end function getOa
Paul T
More information about the Fortran
mailing list