[Patch, fortran] PR31011 - Incorrect error: parameter array sections

Paul Richard Thomas paul.richard.thomas@gmail.com
Thu Mar 8 06:47:00 GMT 2007

:ADDPATCH fortran:

This PR arises because the arithmetic for calculating section lengths
in expr.c(find_array_section) was plain and simple wrong.  I do not
want to investigate when this error was made because I suspect that I
was the culprit, when I wrote the function:)

In the present trunk, the length is calculated as:

length = (end - start + abs(stride)/stride)/stride

This fails for the section (1:3:2) in the reporter's example.  Change
the 3 to 4 and the correct result is obtained.

I have corrected the calculation to:

length = (end -start + stride)/stride

This has the gratifying property that it gives the correct result.

The attached testcase is a slight modification of the reporter's.

Bootstrapped and regtested on x86_ia64/FC5

OK for trunk and 4.2, in the fullness of time?


2007-03-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31011
	* expr.c (find_array_section): Correct arithmetic for section

2007-03-08  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/31011
	* gfortran.dg/parameter_array_section_2.f90: New test.

Winston Churchill: "I like pigs. Dogs look up to us. Cats look down on
us. Pigs treat us as equals."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr31011.diff
Type: text/x-patch
Size: 778 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070308/67ff1ea4/attachment.bin>

More information about the Gcc-patches mailing list