This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/gfortran] Partial fix for PR fortran/20879


Steve Kargl wrote:
> --- 922,978 ----
>   
>   
>   try
> + gfc_check_ichar_iachar (gfc_expr * c) /* sgk */

The information from the comment is available via 'cvs ann'.

> +     case EXPR_VARIABLE:
> +       if (c->ref)
> + 	{
> + 	  if (c->ref->type == REF_ARRAY && c->ts.cl && c->ts.cl->length
> + 	      && c->ts.cl->length->expr_type == EXPR_CONSTANT)
> + 	    i = mpz_get_si (c->ts.cl->length->value.integer);
> + 	  else if (c->ref->u.ss.start->expr_type == EXPR_CONSTANT
> + 		   && c->ref->u.ss.end->expr_type == EXPR_CONSTANT)
> + 	    i = mpz_get_si (c->ref->u.ss.end->value.integer)
> + 	      - mpz_get_si (c->ref->u.ss.start->value.integer) + 1;
> + 	  else
> + 	    return SUCCESS; /* Punt to tree level.  */

This is still wrong.  You have to look through the reference chain, say
something like
  CHARACTER*5 :: c(6)
  i = ichar(c(3)(1:1))
is perfectly valid.  Components would also be broken with this approach.  And
ss.start and ss.end can be NULL, say
  i = ichar(c(3)(:))

I had a look around and I found code which should catch this error in
gfc_simplify_iachar and gfc_simplify_ichar, so maybe we would be better off if
we found out why these functions don't catch the error: the length of the
argument expression is apparently not set before we reach the simplification
routine.

Sorry that I missed this the first time round.

- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]