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 passed as arguments


I'm experiencing a problem with procedure pointers passed as arguments to 
subroutines (using v4.4.0). The subroutine associates the pointer with some 
procedure. The calling unit then attempts to call the procedure pointed to by 
this pointer. When I run this under OpenMP I sometimes get an unassociated 
pointer returned, even though it is associated in the subroutine (and the code 
therefore crashes).


subroutine Outer_Unit
 implicit none
 type(treeNode), pointer :: thisNode
 logical :: procAssigned
 procedure(), pointer :: assignedProc

 call Get_Proc(thisNode,procAssigned,assignedProc)
 if (procAssigned) call assignedProc(thisNode)

 return
end Outer_Unit

subroutine Get_Proc(thisNode,procAssigned,assignedProc)
 implicit none
 type(treeNode), intent(inout), pointer :: thisNode
 logical, intent(out) :: procAssigned
 procedure(), pointer, intent(out) :: assignedProc

 if (decide_if_to_set_the_pointer) then
  assignedProc => Proc_To_Call
  procAssigned=.true.
 else
  procASssigned=.false.
 end if

 return
end subroutine Get_Proc

Outer_Unit and Get_Proc are in two separate modules and Outer_Unit is called 
within an OpenMP parallel region. This all seems to work OK when I compile and 
run without OpenMP. 

My question is, should this be possible (in which case I assume the issue is a 
compiler bug), or am I trying to do something that just can't work?

-A.


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