]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Fix regression on double free on elemental function [PR118747]
authorAndre Vehreschild <vehre@gcc.gnu.org>
Wed, 26 Feb 2025 13:30:13 +0000 (14:30 +0100)
committerAndre Vehreschild <vehre@gcc.gnu.org>
Mon, 3 Mar 2025 07:55:59 +0000 (08:55 +0100)
commit43c11931acc50f3a44efb485b03e6a8d44df97e0
treeb27a3a3329718d5eb2a5f476bbd298c14abcef46
parent0163d5052dcb5e517da95a9b518f98a5ba3138dd
Fortran: Fix regression on double free on elemental function [PR118747]

Fix a regression were adding a temporary variable inserted a copy of the
argument to the elemental function.  That copy was then later used to
free allocated memory, but the freeing was not tracked in the source
array correctly.

PR fortran/118747

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_trans_array_ctor_element): Remove copy to
temporary variable.
* trans-expr.cc (gfc_conv_procedure_call): Use references to
array members instead of copies when freeing after use.
Formatting fix.

gcc/testsuite/ChangeLog:

* gfortran.dg/alloc_comp_auto_array_4.f90: New test.
gcc/fortran/trans-array.cc
gcc/fortran/trans-expr.cc
gcc/testsuite/gfortran.dg/alloc_comp_auto_array_4.f90 [new file with mode: 0644]