[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 anlauf at gcc dot gnu.org changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED Target Milestone|--- |13.3 --- Comment #7 from anlauf at gcc dot gnu.org --- Fixed on mainline for gcc-14, and backported to 13-branch. Closing.
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 --- Comment #6 from CVS Commits --- The releases/gcc-13 branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:63d18dffeb34e58a8ef79ca614f854e055355043 commit r13-7656-g63d18dffeb34e58a8ef79ca614f854e055355043 Author: Harald Anlauf Date: Thu Jul 27 21:30:26 2023 +0200 Fortran: do not pass hidden character length for TYPE(*) dummy [PR110825] gcc/fortran/ChangeLog: PR fortran/110825 * gfortran.texi: Clarify argument passing convention. * trans-expr.cc (gfc_conv_procedure_call): Do not pass the character length as hidden argument when the declared dummy argument is assumed-type. gcc/testsuite/ChangeLog: PR fortran/110825 * gfortran.dg/assumed_type_18.f90: New test. (cherry picked from commit 02f4ca0df2d69b922a622e7cc9b396cf686d5a0f)
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 --- Comment #5 from CVS Commits --- The master branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:02f4ca0df2d69b922a622e7cc9b396cf686d5a0f commit r14-2856-g02f4ca0df2d69b922a622e7cc9b396cf686d5a0f Author: Harald Anlauf Date: Thu Jul 27 21:30:26 2023 +0200 Fortran: do not pass hidden character length for TYPE(*) dummy [PR110825] gcc/fortran/ChangeLog: PR fortran/110825 * gfortran.texi: Clarify argument passing convention. * trans-expr.cc (gfc_conv_procedure_call): Do not pass the character length as hidden argument when the declared dummy argument is assumed-type. gcc/testsuite/ChangeLog: PR fortran/110825 * gfortran.dg/assumed_type_18.f90: New test.
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 anlauf at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org --- Comment #4 from anlauf at gcc dot gnu.org --- Submitted: https://gcc.gnu.org/pipermail/fortran/2023-July/059658.html
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 --- Comment #3 from Steve Kargl --- On Wed, Jul 26, 2023 at 08:54:01PM +, 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.
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 anlauf at gcc dot gnu.org changed: What|Removed |Added CC||anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- Untested fix: diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index ef3e6d08f78..a1eac8e611e 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7521,6 +7521,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && !(fsym && fsym->ts.type == BT_DERIVED && fsym->ts.u.derived && fsym->ts.u.derived->intmod_sym_id == ISOCBINDING_PTR && fsym->ts.u.derived->from_intmod == INTMOD_ISO_C_BINDING ) + && !(fsym && fsym->ts.type == BT_ASSUMED) && !(fsym && UNLIMITED_POLY (fsym))) vec_safe_push (stringargs, parmse.string_length);
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
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. What if the caller passed a type other than character? 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? 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
[Bug fortran/110825] TYPE(*) dummy argument to generate an unused hidden argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110825 kargl at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Priority|P3 |P4 Ever confirmed|0 |1 Known to fail||13.1.1, 14.0 Last reconfirmed||2023-07-26