https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91196
Bug ID: 91196 Summary: Interface generated for proc with VALUE,OPTIONAL misses hidden is-present argument Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Cf. PR fortran/35203 for the original implementation. The following code generates the procedure definition - note the last two arguments: foo (void * x, integer(kind=4)[1] * y, integer(kind=4) * z, integer(kind=4) z2, logical(kind=1) _z2) In the main program, the interface / prototype is declared, but it lacks the hidden logical argument: static logical(kind=1) foo (void *, integer(kind=4)[1] *, integer(kind=4) *, integer(kind=4)); NOTE: The call does have the additional argument: is_present = foo (c_ptr.0, &y, 0B, 0, 0); Example Fortran code - "z2" is the argument of interest. use iso_c_binding implicit none logical(kind=c_bool) :: is_present integer :: y(1) y(1) = 5 is_present = foo(c_null_ptr, y) contains logical(kind=c_bool) function foo(x, y, z, z2) type(c_ptr), value :: x ! Matches a C 'void *' pointer integer, target :: y(1) integer, optional :: z integer, value, optional :: z2 foo = present(z2) end function foo end