https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98342
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Paul Thomas <pa...@gcc.gnu.org>: https://gcc.gnu.org/g:5159b88ef1a1774ec8851c6b92794ae2bf6e0b74 commit r11-7362-g5159b88ef1a1774ec8851c6b92794ae2bf6e0b74 Author: Paul Thomas <pa...@gcc.gnu.org> Date: Wed Feb 24 16:00:51 2021 +0000 Fortran: Fix memory problems with assumed rank formal args [PR98342]. 2021-02-24 Paul Thomas <pa...@gcc.gnu.org> gcc/fortran PR fortran/98342 * trans-expr.c (gfc_conv_derived_to_class): Add optional arg. 'derived_array' to hold the fixed, parmse expr in the case of assumed rank formal arguments. Deal with optional arguments. (gfc_conv_procedure_call): Null 'derived' array for each actual argument. Add its address to the call to gfc_conv_derived_to_ class. Access the 'data' field of scalar descriptors before deallocating allocatable components. Also strip NOPs before the calls to gfc_deallocate_alloc_comp. Use 'derived' array as the input to gfc_deallocate_alloc_comp if it is available. * trans.h : Include the optional argument 'derived_array' to the prototype of gfc_conv_derived_to_class. The default value is NULL_TREE. gcc/testsuite/ PR fortran/98342 * gfortran.dg/assumed_rank_21.f90 : New test.