http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50612
Bug #: 50612 Summary: C_FUNLOC takes the wrong address (result variable not function address) Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Based on the discussion at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/4df24f6197eb142a In the following program C_FUNLOC takes the address of the result variable and not the one of the function itself. I have not checked whether the code is valid, but if it is, the function address should be taken -- and if it is invalid, an error should be printed. integer function foo() bind(C) use iso_c_binding implicit none type(c_funptr) :: fptr fptr = c_funloc(foo) ! takes address of result variable! foo = 42 end function foo