https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Jul 26, 2023 at 08:54:01PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825
> 
> --- Comment #1 from anlauf at gcc dot gnu.org ---
> (In reply to kargl from comment #0)
> > Thus, when compiled and executed the program hits 'STOP 1'.  Likely,
> > gfortran needs to add a possibly unused hidden argument to the argument list
> > for a TYPE(*) dummy argument.
> 
> I guess it should be the other way around: if the dummy argument is TPYE(*),
> we only pass a reference to the actual argument, but no hidden argument,
> as is the case for bind(c).  This is also what the called procedure expects.

I had not thought about how gfortran handles bind(c).  In my codes that
use bind(c), I use an array with character(len=1) with the last element
set to c_null_char.  On the C side, it looks like a C null-terminated
string. 

I don't use type(*) in my codes, so I'm unsure how, or even if,
the length type parameter would/(need to) be passed along.

> What if the caller passed a type other than character?

That's why I wrote '***possibly unused*** hidden argument'

> So we just need to update the caller (the "monster" gfc_conv_procedure_call).
> 
> Do you have an idea what would be the use of the hidden argument here anyway?

Hmmm, a scan of F2018 suggest that type(*) has rather limited uses

   C710  An assumed-type variable name shall not appear in a designator
      or expression except as an actual argument corresponding to a dummy
      argument that is assumed-type, or as the first argument to the
      intrinsic function IS_CONTIGUOUS, LBOUND, PRESENT, RANK, SHAPE, SIZE,
      or UBOUND, or the function C_LOC from the intrinsic module ISO_C_BINDING.

I suspect that a hidden argument isn't needed.  This means
that gfc_conv_procedure_call will need to suppress a hidden
argument for a type(*) dummy argument when the actual argument
is of character type.

> As TYPE(*) is rather new, and I did not find any mentioning of it in the
> ABI specification, we should clarify what we want and also document it at
> 
> https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html

Sorry, I cannot be of much help.  type(*) is well off my radar for
my owns codes.

Reply via email to