This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, Fortran] Fix PR 66041
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: Thomas Koenig <tkoenig at netcologne dot de>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 10 May 2015 15:30:52 +0200
- Subject: Re: [patch, Fortran] Fix PR 66041
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header dot from=mikael dot morin at sfr dot fr
- References: <554D348A dot 2050509 at netcologne dot de> <554DF684 dot 2000800 at sfr dot fr> <554E8AB6 dot 7000101 at netcologne dot de>
Hello,
Le 10/05/2015 00:31, Thomas Koenig a Ãcrit :
> Am 09.05.2015 um 13:59 schrieb Mikael Morin:
>>> + /* We have to get rid of the shape, if thre is one. Do
>>> + so by freeing it and calling gfc_resolve to rebuild it,
>>> + if necessary. */
>>> +
>>> + if (lbound_e->shape)
>>> + gfc_free_shape (&(lbound_e->shape), lbound_e->rank);
>>> +
>>
>>> + lbound_e->rank = ar->dimen;
>> ar->dimen is not what you think it is.
>> It is 3 for array(1, 1, :), while the rank is 1.
>
>> gfc_resolve_expr should set the rank for you, so just remove this line.
>
> It doesn't (for whatever reason), so I kept on setting it.
It seems to work here.
In fact ar->dimen is the correct setting here, as the array is full.
But it will be overwritten (by the same value) in gfc_resolve_expr.
Anyway, it doesn't matter.
>
>>> +
>>> + gfc_resolve_expr (lbound_e);
>>> + lbound = get_array_inq_function (GFC_ISYM_LBOUND,
>>> + lbound_e, i + 1);
>> free lbound_e?
>
> It will be part of the lbound expression, or be simplified away.
get_array_inq_function makes a copy, so a _copy_ of lbound_e is in lbound.
>>> @@ -2639,6 +2665,8 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index,
>>> i_index ++;
>>> }
>>> }
>>> + gfc_free_expr (e_in);
>>> +
>> This side effect is asking for trouble.
>> Instead of this, remove the copies made in the callers.
>> This is independant from the rest, so it can be made later as a follow-up.
>
> Done (all in once).
>
e_in is a copy of ei and is used unmodified as input for the copy to
lbound_e, so it can be removed completely.
OK with that change. Thanks.
Mikael