https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90072
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Andre Vehreschild <ve...@gcc.gnu.org>: https://gcc.gnu.org/g:51046e46ae66ca95bf2b93ae60f0c4d6b338f8af commit r15-1090-g51046e46ae66ca95bf2b93ae60f0c4d6b338f8af Author: Andre Vehreschild <ve...@gcc.gnu.org> Date: Wed Jul 19 11:57:43 2023 +0200 Fix returned type to be allocatable for user-functions. The returned type of user-defined function returning a class object was not detected and handled correctly, which lead to memory leaks. PR fortran/90072 gcc/fortran/ChangeLog: * expr.cc (gfc_is_alloc_class_scalar_function): Detect allocatable class return types also for user-defined functions. * trans-expr.cc (gfc_conv_procedure_call): Same. (trans_class_vptr_len_assignment): Compute vptr len assignment correctly for user-defined functions. gcc/testsuite/ChangeLog: * gfortran.dg/class_77.f90: New test.