https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93814
--- Comment #20 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Paul Thomas <[email protected]>: https://gcc.gnu.org/g:5ddebb97e280917019f58f6a3a1d9e286934c8ff commit r14-12583-g5ddebb97e280917019f58f6a3a1d9e286934c8ff Author: Christopher Albert <[email protected]> Date: Tue Mar 31 08:45:28 2026 +0200 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]> (cherry picked from commit 0ea3035ffbf1bfbc0274673fce367e9f6c6bc8e7)
