J3/15-118 To: J3 Members From: Daniel Chen Subject: F2008 interp: contiguity of assumed-size dummy of bind(c) Date: 2015 February 02 ---------------------------------------------------------------------- NUMBER: F08/ ! /interp assigns number after submission TITLE: contiguity of an explicit-shape or assumed-size array dummy argument with assumed character length of a bind(c) procedure KEYWORDS: CONTIGUITY, BIND(C) DEFECT TYPE: ! /interp assigns STATUS: J3 consideration in progress QUESTION: Should the Fortran processor handle the contiguity of an explicit-shape or assumed-size array dummy argument with assumed character length of a bind(c) procedure? Consider the following code fragment: subroutine sub(arg1, arg2) bind(c) character(*) :: arg1(*) character(*) :: arg2(2,3) ..... ..... end subroutine Both arg1 and arg2 are contiguous according to 5.3.7p2 [97:21]. TS29113 specifies that arg1 and arg2 correspond to a CFI descriptor as they have assumed character length. However, it does not explicitly specify if the Fortran processor needs to handle the contiguity for arg1 and arg2 in the case that the caller is a C function that passes non-contiguous CFI descriptor actual arguments. I found the following at 15.3.7p5 [453:11-16] as: "In an invocation of an interoperable procedure whose Fortran interface has an assumed-shape or assumed-rank dummy argument with the CONTIGUOUS attribute, the associated effective argument may be an array that is not contiguous or the address of a C descriptor for such an array. If the procedure is invoked from Fortran or the procedure is a Fortran procedure, the Fortran processor will handle the difference in contiguity. If the procedure is invoked from C and the procedure is a C procedure, the C code within the procedure shall be prepared to handle the situation of receiving a discontiguous argument." ANSWER: Yes. The Fortran processor needs to handle the difference in contiguity. EDITS to 14-007r2: [453:12 15.3.7p5] After "CONTIGUOUS attribute," add the following: "or an explicit-shape or assumed-size array dummy argument with assumed character length," SUBMITTED BY: Daniel Chen HISTORY: yy-nnn mxxx F08/nnnn submitted ----------------------------------------------------------------------