Request for comment: Character substring lengths
Tobias Burnus
burnus@net-b.de
Mon May 7 16:15:00 GMT 2007
Hi,
FX Coudert wrote:
> Doesn't the following alone fix problems?
>> + /* Set the length to the substring length, if known at compile
>> time. */
>> + if (ref->u.ss.start->expr_type == EXPR_CONSTANT
>> + && ref->u.ss.end->expr_type == EXPR_CONSTANT)
>> + {
>> + mpz_sub (ref->u.ss.length->length->value.integer,
>> + ref->u.ss.end->value.integer,
>> + ref->u.ss.start->value.integer);
I played around a bit more. This does not work: If I use
p => s(2:3)
then len(s) is 2. One could use a new ref->u.ss.ss_length instead of
ref->u.ss.length, but this looks clumsy. In addition, it won't work for
symbols as they only have ts.cl->length -- and for substrings this is
zero. One could copy ref->u.ss.ss_length to the symbol. Is this the
right approach?
Tobias Schlüter wrote:
> Indeed, I found about this recently when I prepared my last series of
patches.
> I think I wrote something about this in one of my patch submissions
You don't mean the following, do you? Or do you?
> I just had the following idea for a beginner's project: we could get
> rid of these double-checks by having a global gfc_charlen
> gfc_empty_cl, whose length member would be initialized to NULL
> (happens automatically, as it's in global storage). Then, instead of
> zeroing ts.cl if the charlen is not known, we would make it point to
> &gfc_empty_cl. Then ts.cl would never be NULL, and ts.cl->length ==
> NULL would be necessary and sufficient for an unknown length.
But I don't see how it would help.
Tobias
More information about the Fortran
mailing list