https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128509

--- Comment #1 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:b5cb04680942a791839d33224064e8cc86b2e7fa

commit r17-6021-gb5cb04680942a791839d33224064e8cc86b2e7fa
Author: Jerry DeLisle <[email protected]>
Date:   Fri Nov 6 10:39:39 2026 -0800

    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