https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105012
--- Comment #36 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Mikael Morin <mik...@gcc.gnu.org>: https://gcc.gnu.org/g:5d645a9dbda0174a25358bf5090640acedec1159 commit r12-8825-g5d645a9dbda0174a25358bf5090640acedec1159 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Mon Aug 29 11:19:29 2022 +0200 fortran: Fix invalid function decl clobber ICE [PR105012] The fortran frontend, as result symbol for a function without declared result symbol, uses the function symbol itself. This caused an invalid clobber of a function decl to be emitted, leading to an ICE, whereas the intended behaviour was to clobber the function result variable. This change fixes the problem by getting the decl from the just-retrieved variable reference after the call to gfc_conv_expr_reference, instead of copying it from the frontend symbol. PR fortran/105012 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_conv_procedure_call): Retrieve variable from the just calculated variable reference. gcc/testsuite/ChangeLog: * gfortran.dg/intent_out_15.f90: New test. (cherry picked from commit edaf1e005c90b311c39b46d85cea17befbece112)