[Patch, fortran] PR29422 and PR29428 - allocatable component wrinkles
Paul Thomas
paulthomas2@wanadoo.fr
Thu Oct 12 07:15:00 GMT 2006
Richard,
> On Oct 11, 2006, at 3:05 PM, Brooks Moses wrote:
>
>> I think it's more an "unimplemented feature" than a "bug" -- unless
>> I'm quite missing something, allocate-on-assignment is only part of
>> F2003, not part of TR-15581, and none of the compilers in question
>> are claiming to have full F2003 support.
>
>
> Ah, yes. I forgot about that distinction, but you are correct. I
> regarded it as an oddity of the TR that the complicated case
> (assignment with an allocatable component) was covered, but the
> corresponding simpler case (assignment of an allocatable without
> components being involved) was omitted. It seems so "obvious" that
> one would do the simple case first, but I forgot that we didn't. That
> is I forgot until you reminded me.
>
I wondered about that whilst we were developing the allocatable
component patch. Since I could see no reference to it in TR15581, I
assumed that there was some reason for its omission:
It would be no big deal to add it, as an F2003 extension. However, it
would come at a price: the code to perform the assignment would have to
be loaded with the statements to detect whether or not there is memory
allocated to the lhs, whether it is sufficient to receive the rhs and to
do the dellocation/allocation, if necessary. I concluded that this was
the reason for the omission. I guess that it should be something that
happens only if standard -f2k is selected, rather than being disallowed
if it is not?
On the question of the bounds; yes, it is ease of implementation that
drove gfortran's behaviour. We do a straight structure assignment to
transfer the descriptor, in both assignments and constructors; thereby
gathering up the bounds of the source. Renormalisation could be
accomplished relatively easily but, again, at the expense of extra
code. In discussing PR29391 with FX, he quoted:
"That's because of F95 13.14.53:
Case (i): For an array section or for an array expression other than a whole
array or array structure component, LBOUND(ARRAY, DIM) has the value 1.
For a
whole array or array structure component, LBOUND(ARRAY, DIM) has the value:
(a) equal to the lower bound for subscript DIM of ARRAY if dimension DIM of
ARRAY does not have extent zero or if ARRAY is an assumed-size array of rank
DIM, or
(b) 1 otherwise."
which seems to me to say that we can leave allocatable components as
they are (but that the cases in PR29391 have to
be corrected).
Dominique, unless we hear anything to the contrary very soon, I guess
that you can scrub that PR. However, I will comment the appropriate
test cases to say that the bounds checks are gfortran specific and test
that the descriptors have been correctly assigned. Thanks for raising this.
Paul
More information about the Fortran
mailing list