GFC_TYPE_ARRAY_LBOUND and descriptors
Mikael Morin
mikael.morin@sfr.fr
Thu Aug 19 13:21:00 GMT 2010
Le 19.08.2010 10:33, Daniel Kraft a écrit :
>
> Hi,
>
> I've just stumbled upon something which I can not make sense of... And
> hope someone will help me. In trans, I work (for the pointer bounds/rank
> remapping patch) with array descriptors; to query their bounds, I use
> things like
>
> gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[dim])
>
> which works fine. Now I just discovered that there are functions like
>
> gfc_conv_array_lbound (desc, dim)
>
> that are not only shorter to type (useful with 80 character lines :P)
> but also seem to me to be "the correct" ones to query an lbound.
> However, this function returns in my case 0 although the descriptor's
> lbound is 2, thus if I use those I get miscompiled code.
>
> Now, looking at gfc_conv_array_lbound suggests that it first tries to
> use GFC_TYPE_ARRAY_LBOUND and uses gfc_conv_descriptor_lbound_get if
> this fails. GDB shows me that GFC_TYPE_ARRAY_LBOUND does return 0 for a
> type-argument printed as "struct array1_integer(kind=4)". Although this
> is more or less just a "gut feeling", I do not understand why this is
> the case and not a NULL_TREE is returned. I would have thought that
> GFC_TYPE_ARRAY_LBOUND returns NULL for descriptors and just a bound if
> it is some kind of descriptor-less array.
>
> So what's wrong with my thinking? Any clarification is appreciated...
> Although I think I'm just going with the *conv_descriptor* functions
> which seem to do what I need.
>
> Yours,
> Daniel
>
Hello,
I think that even in the case of a descriptor, we try to put as much
information as possible in the array type. In gfc_get_array_type_bounds,
we record the bounds if there are constants.
In gfc_conv_expr_descriptor, I bet you get a zero loop.from, so that you
call gfc_get_array_type_bounds with a known-to-be-zero lower bound.
Then gfc_conv_array_lbound assumes the bound is known and bypasses the
value from the descriptor.
From my point of view this behaviour is desirable. We should be able to
get the right bounds right from the beginning ; no need to modify the
descriptor twice or more. It should even be possible to mark the
descriptor as read-only if it was properly initialized. But I'm afraid
that you have to stick to the gfc_conv_desscriptor_*{s,g}et functions
for the time being.
Mikael
More information about the Fortran
mailing list