On 11/14/26 6:03 PM, Jerry DeLisle wrote:
See attached patch. A dummy function whose result is CHARACTER(n), with
n one of its own dummy arguments, caused an ICE in gfc_get_symbol_decl.
gfc_trans_deferred_vars treated the dummy function like a CHARACTER
dummy variable and tried to evaluate n in the caller, where n has no
declaration. gfc_conv_procedure_call already evaluates the result length
at each call, so the patch skips that setup for a dummy function. I also
checked at run time that calls through CHARACTER(*), PROCEDURE() and
procedure pointer dummy functions still return the right length.
The fix is in gfc_trans_deferred_vars in trans-decl.cc; the rest is the
new test.
Regression tested on x86_64.
I will commit as simple and obvious.
Regards,
Jerry
The master branch has been updated by Jerry DeLisle <[email protected]>:
https://gcc.gnu.org/g:9f485bb6ac443e89e25e67069ace874a1c99d9c0
commit r17-6330-g9f485bb6ac443e89e25e67069ace874a1c99d9c0
---
fortran: [PR107144] ICE for dummy function returning CHARACTER(n)
gfc_trans_deferred_vars set up the result length of a CHARACTER dummy
function as it does the length of a CHARACTER dummy variable. When that
length is an argument of the dummy function itself, the argument is
never declared in the caller, so gfc_get_symbol_decl failed an
assertion. The result length is evaluated at each call, so skip the
setup for a dummy function.
Assisted-by: Claude Opus 5.5
PR fortran/107144
gcc/fortran/ChangeLog:
* trans-decl.cc (gfc_trans_deferred_vars): Do not set up the result
length of a CHARACTER dummy function.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr107144.f90: New test.