Hi Jerry!

Am 07.11.26 um 1:16 AM schrieb Jerry D:
See the attached patch.

This is a followup to the PR128357 patch fixing the additional case identified by Harald. It turns out to be not too difficult.

Regression tested on x86_64.

OK for mainline?

This is OK.  Thanks for the quick fix!

Harald

Regards,

Jerry

---

fortran: [PR128509] Double free with a parenthesized array constructor

The allocatable components of the elements of a parenthesized array
constructor were freed after the call while still shared with the
variables in the constructor, which then freed them again.  The
temporary for the parenthesized expression was a shallow copy of the
constructor's temporary, because only a variable or a constructor got a
deep copy, and for an elemental procedure the parentheses hid the
variables from expr_may_alias_variables.  Treat a parenthesized array
constructor like the constructor in both places.

Assisted-by: Claude Opus 5.5

     PR fortran/128509

gcc/fortran/ChangeLog:

     * trans-array.cc (gfc_conv_expr_descriptor): Copy the temporary for
     a parenthesized array constructor deeply, as for the constructor.
     * trans-expr.cc (expr_may_alias_variables): Look through the
     parentheses around an array constructor.

gcc/testsuite/ChangeLog:

     * gfortran.dg/asan/paren_array_ctor_alloc_comp_1.f90: New test.
---

Reply via email to