This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran, 66035, v1] [5/6 Regression] gfortran ICE segfault
- From: Andre Vehreschild <vehre at gmx dot de>
- To: Mikael Morin <mikael dot morin at sfr dot fr>
- Cc: GCC-Patches-ML <gcc-patches at gcc dot gnu dot org>, GCC-Fortran-ML <fortran at gcc dot gnu dot org>
- Date: Mon, 11 May 2015 12:40:06 +0200
- Subject: Re: [Patch, Fortran, 66035, v1] [5/6 Regression] gfortran ICE segfault
- Authentication-results: sourceware.org; auth=none
- References: <20150508152950 dot 182a4c1a at gmx dot de> <554F573D dot 9030909 at sfr dot fr>
Hi Mikael,
> > diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
> > index cf607d0..402d9b9 100644
> > --- a/gcc/fortran/trans-expr.c
> > +++ b/gcc/fortran/trans-expr.c
> > @@ -6881,6 +6881,30 @@ alloc_scalar_allocatable_for_subcomponent_assignment
> > (stmtblock_t *block, TREE_TYPE (tmp), tmp,
> > fold_convert (TREE_TYPE (tmp),
> > size)); }
> > + else if (cm->ts.type == BT_CLASS)
> > + {
> > + gcc_assert (expr2->ts.type == BT_CLASS || expr2->ts.type ==
> > BT_DERIVED);
> > + if (expr2->ts.type == BT_DERIVED)
> > + {
> > + tmp = gfc_get_symbol_decl (gfc_find_vtab (&expr2->ts));
> > + tmp = gfc_build_addr_expr (NULL_TREE, tmp);
> > + size = fold_convert (size_type_node, gfc_vptr_size_get (tmp));
> > + }
> Use TYPE_SIZE_UNIT of the rhs in this case, in the same way as in the
> else branch further below.
Er, but when I get TYPE_SIZE_UNIT () correctly, then it will grab the size
needed to store the %_vptr%size component. Do you really intent that? I need to
alloc the size of the polymorphic type of expr2 here.
<snipp>
> > @@ -7008,7 +7032,9 @@ gfc_trans_subcomponent_assign (tree dest,
> > gfc_component * cm, gfc_expr * expr, gfc_add_expr_to_block (&block, tmp);
> > }
> > else if (init && (cm->attr.allocatable
> > - || (cm->ts.type == BT_CLASS && CLASS_DATA
> > (cm)->attr.allocatable)))
> > + || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable
> > + && (expr->ts.type != BT_CLASS
> > + || CLASS_DATA (expr)->attr.allocatable))))
> maybe: || !CLASS_DATA (expr)->attr.allocatable
> (with a '!')?
No, I only want to copy the rhs to new memory, when it is allocatable. For all
other cases, one should not do this, to prevent a memory leak. Furthermore, is
the data copied to freshly allocated memory anyway. Have a look at the pseudo
code generated for the testcase in the patch.
Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de