[Patch, fortran] PR61138 Wrong code with pointer-bounds remapping
Mikael Morin
mikael.morin@sfr.fr
Mon Feb 9 12:54:00 GMT 2015
Hello,
this is about a pointer bounds remapping regression introduced at
http://gcc.gnu.org/r190641
That revision introduced support for se.descriptor_only in
gfc_conv_expr_descriptor with this hunk:
> Index: trans-array.c
> ===================================================================
> --- trans-array.c (révision 220514)
> +++ trans-array.c (copie de travail)
> @@ -6574,7 +6574,7 @@ gfc_conv_expr_descriptor (gfc_se *se, gfc_expr *ex
> /* Create a new descriptor if the array doesn't have one. */
> full = 0;
> }
> - else if (info->ref->u.ar.type == AR_FULL)
> + else if (info->ref->u.ar.type == AR_FULL || se->descriptor_only)
> full = 1;
> else if (se->direct_byref)
> full = 0;
The problem comes from gfc_trans_pointer_assign, which uses several
times the same gfc_se struct, the first time with descriptor_only set,
the other times without clearing it.
This was not a problem before the above change, because the flag wasn't
looked at.
After the change however, one should make sure that descriptor_only is
not inherited from a previous use.
The fix proposed clears the flag upon reuse, which should match exactly
the original behaviour, making it rather safe, and suitable also for the
branches.
I have to admit that I'm not completely satisfied with it however.
I would prefer no GFC_SE reuse at all, namely collect every piece of
code in a separate struct, and merge them later explicitly into a block.
Alas, the code is not exactly straightforward to my eyes, and my
attempt in that direction to sneak some orthogonality in that madness
failed.
Anyway, regression tested on x86_64-linux, OK for trunk/4.9/4.8 ?
Mikael
-------------- next part --------------
2015-02-09 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/61138
* trans-expr.c (gfc_trans_pointer_assignment): Clear DESCRIPTOR_ONLY
field before reusing LSE.
2015-02-09 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/61138
gfortran.dg/pointer_remapping_9.f90: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr61138.diff
Type: text/x-patch
Size: 1153 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150209/0d24113c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pointer_remapping_9.f90
Type: text/x-fortran
Size: 670 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150209/0d24113c/attachment-0001.bin>
More information about the Fortran
mailing list