See http://gcc.gnu.org/ml/fortran/2007-09/msg00301.html for the initial bug report by Salvatore Filippone (thanks for finding the bug!) and a longer example.
Assume the following code: type double_vector_item real(c_double), allocatable :: v(:) end type double_vector_item type(double_vector_item), target :: dbv_pool While V(:) itself is does not have the TARGET attribut, dbv_pool%v has it due to the following clause in the Fortran 2003 standard ("5.1.2.14 TARGET attribute"): "If an object has the TARGET attribute, then all of its nonpointer subobjects also have the TARGET attribute." Additionally, "real(c_double)" is of interoperable type and kind; thus the following clause of "15.1.2.5 C LOC (X)" applies to dbv_pool%v: "Argument. X shall [...] (1) have interoperable type and type parameters and be [...] (b) an allocated allocatable variable that has the TARGET attribute and is not an array of zero size". I did not investigate in detail, but gfortran seems to fail (in resolve.c's gfc_iso_c_func_interface) at /* See if we have interoperable type and type param. */ if (verify_c_interop (&(args->expr->symtree->n.sym->ts), args->expr->symtree->n.sym->name, &(args->expr->where)) == SUCCESS || gfc_check_any_c_kind (&(args_sym->ts)) == SUCCESS) Notes: - dbv_pool itself is not C interoperable as it has no BIND(C) - at it cannot have this attribute at V is allocatable. - V cannot have an explicit TARGET attribute as it is a TYPE component - sunf95 has the same problem as gfortran, but ifort 10, NAG f95 and g95 accept this program. -- Summary: Bind(C): C_LOC rejects interoperable arguments Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org OtherBugsDependingO 32630 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33497