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

--- Comment #8 from Harald Anlauf <anlauf at gmx dot de> ---
It's not as trivial as I had hoped.

The point is that gfc_element_size() and gfc_target_expr_size()
are returning size 0 for the source expression, which is an entirely
correct value.  However, they also return value 0 also for cases
where the sizes could not be determined to be a constant.

I have a 'half-patch' that tries to change gfc_target_expr_size()
to return a bool which is true for success and false for failure,
and then deal with this return value.

It seems that this also needs to be done for gfc_element_size().
However, there is this occurrence in class.c of gfc_element_size():

              /* Build a minimal expression to make use of
                 target-memory.c/gfc_element_size for 'size'.  Special handling
                 for character arrays, that are not constant sized: to support
                 len (str) * kind, only the kind information is stored in the
                 vtab.  */
              e = gfc_get_expr ();
              e->ts = *ts;
              e->expr_type = EXPR_VARIABLE;
              c->initializer = gfc_get_int_expr (gfc_size_kind,
                                                 NULL,
                                                 ts->type == BT_CHARACTER
                                                 ? ts->kind
                                                 : gfc_element_size (e));

I am not yet sure how to safely rewrite this.

Reply via email to