[Patch, Fortran] PR 38324 Wrong array bounds for array implicit sections of derived components

Mikael Morin mikael.morin@tele2.fr
Wed Jan 28 23:09:00 GMT 2009


Hi all,

I'm following the latest trend in gfortran development, namely fixing
ubound (and lbound).

The problem appears in code like this...:
x=struct(ia)
print *, 'bounds, full array           ', lbound(x%ib), ubound(x%ib)
x=struct(ia(:))
print *, 'bounds, full implicit section', lbound(x%ib), ubound(x%ib)
x=struct(ia(from:to))
print *, 'bounds, full explicit section', lbound(x%ib), ubound(x%ib)

... returning this:
 bounds, full array                     -1           2
 bounds, full implicit section          -1           2    <-- should not
it be 1 4 as above?
 bounds, full explicit section           1           4

(The comment is from Dominique ;-) )

The bug lies in gfc_conv_expr_descriptor which is passing array
descriptor as-is in case of a full array section. This is wrong if the
bounds are not 1-based.

This has been there since revision 119990 and probably before, and I
find it strange it was not discovered before.

Now, to trunk or not to trunk, that is the question.

The patch is obvious.
It is impacting a very sensitive function (gfc_conv_expr_descriptor).
It is changing a harmless part of it (deciding whether to keep the
descriptor).
It is regtested on x86_64-unknown-linux-gnu.

Ok for 4.4?
One can wait a bit to decide, so that there is nothing left to decide ;).

Mikael

2009-01-28  Mikael Morin  <mikael.morin@tele2.fr>

	PR fortran/38324
	* gfortran.dg/derived_bounds_1.f90: New test.

2009-01-28  Mikael Morin  <mikael.morin@tele2.fr>

	PR fortran/38324
	* trans-array.c (gfc_conv_expr_descriptor): Disable passing
	descriptor as-is in the full array section case.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr38324_01.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090128/4d1e2655/attachment.ksh>


More information about the Fortran mailing list