https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91963

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Oct 02, 2019 at 06:10:48PM +0000, tkoenig at gcc dot gnu.org wrote:
> 
> You're right, Steve, the problem lies in the simplification
> of the implied DO loop (the error message is a catch-all
> which is somewhat misleading here).
> 

I've looked at this a long time ago.  Never came up with a fix.

In the original code or the conforming example I posted, gfortran
ends up in check.c(kind_check).  If we look at lines 630 and following
we have

  if (!gfc_check_init_expr (k))
    {
      gfc_error ("%qs argument of %qs intrinsic at %L must be a constant",
          gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic,
          &k->where);
      return false;
    }

gfc_check_init_exp() returns ok, so gfortran knows it has an
intialization expression.  It simply hasn't reduced it to a
constant.  The next section of code fails, because extraction
of the kind value fails.

  if (gfc_extract_int (k, &kind)
      || gfc_validate_kind (type, kind, true) < 0)
    {
      gfc_error ("Invalid kind for %s at %L", gfc_basic_typename (type),
           &k->where);
      return false;
    }

This is were I'm stuck.  I think we need to rummage through
gfc_reduce_init_expr().

Reply via email to