[J3] [EXTERNAL] Re: VALUE attribute for assumed-shape in an interface with bind C

Robert Corbett rpcorbett at att.net
Mon Jan 10 17:14:34 UTC 2022

I disagree with Steve’s interpretation of
paragraph 2 of subclause 18.3.6 of the
Fortran 2018 standard.  The statement
“A Fortran procedure interface is interoperable with a C function prototype if”
asserts that if the following list of conditions
is satisfied, the Fortran interface is
interoperable.  In the code provided, the

(1) has the BIND attribute,

(2)(b) describes a subroutine,

(3) could have the same number of
      dummy arguments as a C interface
      has formal parameters,

(4) has no scalar dummy arguments and
      so the condition is trivially true,

(5) has no arguments without the VALUE
      attribute, and so the condition is trivially

(6) has no allocatable or pointer arguments
      of type CHARACTER,  and

(7) the prototype might not have a variable
      number of arguments.

Because the interface satisfies all of the
requirements for being interoperable,
I think it is interoperable given a proper
corresponding C interface.

Robert Corbett

> On Jan 10, 2022, at 8:31 AM, Steve Lionel via J3 <j3 at mailman.j3-fortran.org> wrote:
> On 1/10/2022 11:23 AM, Reuben D. Budiardja wrote:
>> Thanks Steve. I've looked in this section too, and had similar thought, but then, strictly speaking, this can be interpreted as that such procedure is not interoperable with C. 
>> Assummed-size is explicitly prohibited in C867 (along with coarray and variable with coarray ultimate component). I guess I wonder why assumed-shape is not in that list as well.
> Both assumed-size and assumed-shape arrays ARE interoperable (just not with VALUE).  Assumed-size is covered in 18.3.5. For assumed-shape:
> (5) any dummy argument without the VALUE attribute corresponds to a formal parameter of the prototype that is of a pointer type, and either
> ...
>  • the dummy argument is allocatable, assumed-shape, assumed-rank, or a pointer without the CONTIGUOUS attribute, and the formal parameter is a pointer to CFI_cdesc_t, 
> So for an assumed-shape dummy to be interoperable, the corresponding C formal must be a pointer to a C descriptor.
> Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220110/42a0d281/attachment-0001.htm>

More information about the J3 mailing list