Hi Jerry, Please accept my apologies. I became so obsessed with the final wrinkle in PR120140 that I stopped the regression fixes in the middle of processing PR93814. I have tested it and given it a good once over. It is certainly ready for mainline; so please go ahead.
Regards Paul On Fri, 10 Apr 2026 at 22:23, Jerry D <[email protected]> wrote: > > Hi all, > > The attached patch from Christopher regression tested OK here. > > I also compared results to other compilers. I think it is OK. > > Tested on x86_64. > > OK to commit to mainline and backport later after things have settled a bit. > > Regards, > > Jerry > --- > > fortran: Fix ICE in build_entry_thunks with CHARACTER bind(c) > ENTRY [PR93814] > > When a CHARACTER function with bind(c) has an ENTRY also with bind(c), > the entry master function returns CHARACTER by reference (void return, > result passed as pointer + length arguments), but the individual bind(c) > entry thunks return CHARACTER(1) by value and have no such arguments. > > build_entry_thunks unconditionally forwarded result-reference arguments > from the thunk's own parameter list to the master call. For bind(c) > CHARACTER thunks this accessed DECL_ARGUMENTS of a function with no > arguments, causing a segfault. > > Create local temporaries for the result buffer and character length in > the thunk when the master returns by reference but the thunk does not. > After calling the master (which writes through the reference), load > the character value from the local buffer and return it by value. > > PR fortran/93814 > > gcc/fortran/ChangeLog: > > * trans-decl.cc (build_entry_thunks): Create local result buffer > and length temporaries for bind(c) CHARACTER entry thunks when the > master returns by reference but the thunk returns by value. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/pr93814.f90: New test. > > Signed-off-by: Christopher Albert <[email protected]>
