To: J3 J3/22-118 From: Van Snyder Subject: C_F_POINTER's SHAPE argument should be described as upper bounds Date: 2022-February-03 Reference: 22-007 Before adding the LOWER argument to C_F_POINTER, the description of the SHAPE argument argument as specifying the shape of the result was harmless. If a LOWER argument is present, describing the SHAPE argument as specifying the shape instead of the upper bounds is confusing, and incompatible with pointer assignment. Assume X is contiguous and has the POINTER or TARGET attribute. Assume F is a pointer. Assume L and U are rank-1 arrays whose extents are equal to the rank of F, and whose values are the desired lower and upper bounds of F, respectively. Then F(@L:U) => X specifies those bounds. Assume C is of type C_PTR. Then to achieve the effect of the above, assuming some intermediate operation by C interoperability and not all values of L are 1 (else why bother specifing it), one would confusingly need to write C = C_LOC(X) ... (C is passed to a C function) call C_F_POINTER ( C, F, U-L+1, L ) to be equivalent to F(@L:U) => X It would be less confusing if the SHAPE argument were described as the upper bound of the result, allowing C => C_LOC(X) ... (C is passed to a C function) call C_F_POINTER ( C, F, U, L ) to be equivalent to F(@L:U) => X This description is not incompatible with Fortran 2018. When C interoperability was being developed in 1997-2003, after Michael Hennecke's effort was rejected, it was urged that C_F_POINTER ought to include provision to specify both lower and upper bounds, in that order, but that proposal was rejected. Edits ===== [499:30 18.2.3.3p3 C_F_POINTER] Replace "shape is" with "upper bounds are". [499:35 18.2.3.3p3 C_F_POINTER] Replace "SHAPE shall specify a size of 1" with "all elements of SHAPE, or SHAPE - LOWER + 1 if LOWER is present, shall be equal to 1." [499:37 18.2.3.3p3 C_F_POINTER] Replace "SHAPE" with "SHAPE, or SHAPE - LOWER + 1 if LOWER is present,". [499:37 18.2.3.3p3 C_F_POINTER] After "PRODUCT(SHAPE)" insert ", or PRODUCT(SHAPE - LOWER + 1) if LOWER is present". [500:1 18.2.3.3p3 C_F_POINTER] Replace "SHAPE shall specify a size of 1" with "all elements of SHAPE, or SHAPE - LOWER + 1 if LOWER is present, shall be equal to 1." [500:3 18.2.3.3p3 C_F_POINTER] Replace "SHAPE" with "SHAPE, or SHAPE - LOWER + 1 if LOWER is present,". [500:5 18.2.3.3p3 C_F_POINTER] After "PRODUCT(SHAPE)" insert ", or PRODUCT(SHAPE - LOWER + 1) if LOWER is present".