https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128357
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:2397b3b0422d72744b03d1330dc346db4b81846f commit r17-6007-g2397b3b0422d72744b03d1330dc346db4b81846f Author: Jerry DeLisle <[email protected]> Date: Mon Oct 19 15:36:38 2026 -0700 fortran: [PR128357] Memory leaks with parenthesized alloc-comp variables A parenthesized array of a type with allocatable components leaked on each use as an actual argument or ASSOCIATE selector. A TYPE temporary shares the components of the variable, yet after the call it was deep copied into new storage so that its components could be freed, and that storage was never freed. A CLASS temporary is a deep copy made through the vtable, and the components of its elements were never freed. Pass a TYPE temporary without copying or freeing its components, and finalize a CLASS temporary through the vtable after its use. Assisted-by: Claude Opus 5.5 PR fortran/128357 gcc/fortran/ChangeLog: * trans-array.cc (gfc_conv_expr_descriptor): Finalize the temporary for a CLASS operator expression through the vtable. * trans-expr.cc (parenthesized_variable): New function. (gfc_conv_procedure_call): Use it. Do not copy or free the allocatable components of the temporary for a parenthesized TYPE variable. gcc/testsuite/ChangeLog: * gfortran.dg/asan/paren_alloc_comp_leak_1.f90: New test.
