[Patch, fortran] PR27709 - Using size of array pointer component as dimension of function result causes gfortran internal error.
Paul Thomas
paulthomas2@wanadoo.fr
Thu May 25 05:13:00 GMT 2006
:ADDPATCH fortran:
This was http://gcc.gnu.org/ml/fortran/2006-05/msg00357.html and thread.
Well, in spite of living up to my name, I relented and was convinced
that this is good code and that the bug should be fixed. Thanks to
Richard, Brooks and David Ham for a useful discussion.
Not only was I persuaded by this discussion but I was promptly hit by
the same bug myself; so I had a double incentive to fix it.
The problem is clearly indicated in the attached testcase. The internal
error is triggered by multiple component references in an array bound
specification expression.
It turned out that the routine that emits the error,
resolve.c(find_array_spec), is also the cause of it. As it is coded, it
makes no attempt to go any deeper than one component reference and fails
because it only checks the reference against any derived types that it
finds in the primary derived type. Thus, multiple component references
in linked lists work; eg. real, dimension (size (self%next%next%data,
1)) :: local is OK.
The fix is implemented by supplying a gfc_symbol that points to the
derived type used in the last component reference. The components of
this derived type are used for comparison with the next component
reference. The testcase is that posted with the PR.
Regtested on FC5/Athlon1700. OK for trunk and, when reopened, 4.1?
Paul
2006-05-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/27709
* resolve.c (find_array_spec): Add gfc_symbol, derived, and
use to track repeated component references.
2006-05-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/27709
* gfortran.dg/spec_expr_4.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: resolve.diff
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060525/8edac4ab/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spec_expr_4.f90
Type: text/x-fortran
Size: 992 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060525/8edac4ab/attachment-0001.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Change.Logs
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060525/8edac4ab/attachment.ksh>
More information about the Fortran
mailing list