https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128478
--- Comment #2 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:0b8b0a586cff6ec15a97063732cbd1c667825d97 commit r17-6560-g0b8b0a586cff6ec15a97063732cbd1c667825d97 Author: Jerry DeLisle <[email protected]> Date: Fri Nov 6 17:00:22 2026 -0800 fortran: [PR128478] Copy a parenthesized scalar CLASS actual argument A parenthesized scalar CLASS variable passed as an actual argument was not copied, so the dummy aliased the variable, and passing it to a TYPE dummy with allocatable components segfaulted, because the components of the CLASS container were copied and freed as if it were the derived type. Make the value of a parenthesized scalar CLASS variable a copy in gfc_conv_expr_op, made through the vtable and finalized after its use, keep the free of the copy until after the call, and leave its components to the copy's own finalization. Assisted-by: Claude Opus 5.5 PR fortran/128478 gcc/fortran/ChangeLog: * trans-expr.cc (conv_class_value_copy): New function. (gfc_conv_expr_op): Use it to copy a parenthesized scalar CLASS variable. (gfc_conv_procedure_call): Do not copy or free the allocatable components of the copy of a parenthesized scalar CLASS variable. (gfc_conv_expr_reference): Keep the free of that copy in se->post. gcc/testsuite/ChangeLog: * gfortran.dg/asan/paren_class_copy_1.f90: New test.
