[Patch, fortran] PR96495 - [gfortran] Composition of user-defined operators does not copy ALLOCATABLE property of derived type

Paul Richard Thomas paul.richard.thomas@gmail.com
Sat Aug 29 11:50:20 GMT 2020


This patch detects a scalar function result that has allocatable components
and is being used inside a scalarization loop. Before this patch, the
components would be deallocated and nullified within the scalarization loop
and so would cause a segfault on the second cycle of the loop.

The stored result has to be found by identifying the expression in the loop
ss chain. This is then used for the deallocation of the allocatable
components in the loop post block, which keeps gimple happy and prevents
the segfault.

Regtests on FC31/x86_64 - OK for master?

Paul

This patch fixes PR96495 - frees result components outside loop.

2020-29-08  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/96495
* trans-expr.c (gfc_conv_procedure_call): Take the deallocation
of allocatable result components of a scalar result outside the
scalarization loop. Find and use the stored result.

gcc/testsuite/
PR fortran/96495
* gfortran.dg/alloc_comp_result_2.f90 : New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 1393 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200829/5b3857f8/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alloc_comp_result_2.f90
Type: text/x-fortran
Size: 1577 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200829/5b3857f8/attachment-0003.bin>


More information about the Gcc-patches mailing list