[Patch, fortran] PR83118 - [8/9/10/11 Regression] Bad intrinsic assignment of class(*) array component of derived type
Thomas Koenig
tkoenig@netcologne.de
Fri Dec 25 11:04:28 GMT 2020
First of all, merry Christmas everybody!
Regarding the patch:
> Regtests on FC33/x86_64 and the testcase is fixed with -m32. OK for master?
It's OK by me.
There is just one piece of code that I don't understand:
+ if (expr2->expr_type == EXPR_FUNCTION
+ && expr2->ts.type == BT_DERIVED
+ && expr2->ts.u.derived->attr.alloc_comp)
+ {
+ tree tmp2 = gfc_deallocate_alloc_comp (expr2->ts.u.derived,
+ rse.expr, expr2->rank);
+ if (lss == gfc_ss_terminator)
+ gfc_add_expr_to_block (&rse.post, tmp2);
+ else
+ gfc_add_expr_to_block (&loop.post, tmp2);
+ }
+ }
This part appears to do the right thing, but I do have one request.
Could you maybe (for my personal education, and that of others who read
this code) add a comment what "lss = gfc_ss_terminator" tests, and why
it that one or the other post block is selected for adding the
deallocation? I simply don't know what this idiom means.
Thanks for the patch!
Best regards
Thomas
> Paul
>
> Fix failures with -m32 and some memory leaks.
>
> 2020-12-23 Paul Thomas <pault@gcc.gnu.org <mailto:pault@gcc.gnu.org>>
>
> gcc/fortran
> PR fortran/83118
> * trans-array.c (gfc_alloc_allocatable_for_assignment): Make
> sure that class expressions are captured for dummy arguments by
> use of gfc_get_class_from_gfc_expr otherwise the wrong vptr is
> used.
> * trans-expr.c (gfc_get_class_from_gfc_expr): New function.
> (gfc_get_class_from_expr): If a constant expression is
> encountered, return NULL_TREE;
> (gfc_trans_assignment_1): Deallocate rhs allocatable components
> after passing derived type function results to class lhs.
> * trans.h : Add prototype for gfc_get_class_from_gfc_expr.
>
More information about the Fortran
mailing list