[Patch, fortran] PR31803 - Fix pointer => target(range)

Brooks Moses brooks.moses@codesourcery.com
Fri May 4 17:33:00 GMT 2007


Tobias Burnus wrote:
> Index: gcc/fortran/expr.c
> ===================================================================
> --- gcc/fortran/expr.c	(Revision 124415)
> +++ gcc/fortran/expr.c	(Arbeitskopie)
> @@ -2553,6 +2553,7 @@ gfc_check_pointer_assign (gfc_expr *lval
>      return SUCCESS;
>  
>    if (lvalue->ts.type == BT_CHARACTER
> +      && lvalue->ts.cl && rvalue->ts.cl
>        && lvalue->ts.cl->length && rvalue->ts.cl->length
>        && abs (gfc_dep_compare_expr (lvalue->ts.cl->length,
>  				    rvalue->ts.cl->length)) == 1)

But, in the assignment that's failing, the lvalue and rvalue _do_ have a 
well-defined length, just not one that's stored in ts.cl.

What happens with this patch if you do something like this?

   character (len=4), s1
   character (len=20), pointer :: p1
   s1 = 'abcd'
   p1 => s1(2:3)

Is there some other check that catches this?

(It looks like this was a pre-existing situation regardless, since the 
ts.cl->length values are checked for existence, so I'm not objecting to 
the patch; I'm just wondering if it needs a followup....)

- Brooks



More information about the Fortran mailing list