------- Comment #1 from burnus at gcc dot gnu dot org 2009-01-12 13:34 ------- > I think NAG f95 is right by rejecting it with: > Error: line 9: The argument to C_LOC must not be an array pointer
Or maybe not: "15.1.2.5 C_LOC(X)" has for the result value: "(2) If X is an array data entity, the result is determined as if C_PTR were a derived type containing a scalar pointer component PX of the type and type parameters of X and the pointer assignment of CPTR%PX to the first element of X were executed" The example is still wrong as it fails (1c): "Argument. X shall either (1) have interoperable type and type parameters and be (a) a variable that has the TARGET attribute and is interoperable, (b) an allocated allocatable variable that has the TARGET attribute and is not an array of zero size, or (c) an associated scalar pointer, or (2) be a nonpolymorphic scalar, have no length type parameters, and be" Is seems as if a) no-pointer, no-allocatable arrays b) allocatable arrays (allocated without empty size) are allowed. Thus the following programs should be valid -- and it also compiles with NAG f95: use iso_c_binding implicit none type tY REAL (KIND=c_float), dimension(5) :: y_fptr = 5 REAL (KIND=c_float), dimension(:), allocatable :: y_fptr2 Integer (Kind=c_int) :: ny = 0 end type type(ty), target :: y_f type(c_ptr) :: y_cptr y_cptr = c_loc(y_f%y_fptr) allocate(y_f%y_fptr2(2)) y_cptr = c_loc(y_f%y_fptr2) end -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic, ice-on-valid- | |code http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38813