The following program: real, dimension(3,3), parameter :: a=reshape ((/(i, i = 1,9)/),(/3,3/)) real, dimension(2,3) :: b=a(:2:-1,:) real, dimension(2,3) :: c=a(3:2:-1,:) print *, b print *, c end compiles with gfortran and gives: 3.000000 2.000000 6.000000 5.000000 9.000000 8.000000 3.000000 2.000000 6.000000 5.000000 9.000000 8.000000 i.e., b=a(:2:-1,:) is interpreted as c=a(3:2:-1,:) instead of giving: real, dimension(2,3) :: b=a(:2:-1,:) 1 Error: Array assignment at (1) has different sizes (6/0) as required by the following first and last paragraphs (draft f2003): > 6.2.2.3.1 Subscript triplet > > A subscript triplet designates a regular sequence of subscripts > consisting of zero or more subscript values. The third expression in the > subscript triplet is the increment between the subscript values and is > called the stride. The subscripts and stride of a subscript triplet are > optional. An omitted first subscript in a subscript triplet is > equivalent to a subscript whose value is the lower bound for the array > and an omitted second subscript is equivalent to the upper bound. An > omitted stride is equivalent to a stride of 1. > > The stride shall not be zero. > > When the stride is positive, the subscripts specified by a triplet form a > regularly spaced sequence of integers beginning with the first subscript > and proceeding in increments of the stride to the largest such integer > not greater than the second subscript; the sequence is empty if the first > subscript is greater than the second. > > ... > > When the stride is negative, the sequence begins with the first subscript > and proceeds in increments of the stride down to the smallest such > integer equal to or greater than the second subscript; the sequence is > empty if the second subscript is greater than the first. Note that: real, dimension(3,3) :: a real, dimension(2,3) :: b a=1 b=a(:2:-1,:) print *, b end gives correctly: b=a(:2:-1,:) 1 Error: different shape for Array assignment at (1) on dimension 1 (2/0) Dominique
I had better deal with this, since I am teh author of the wrong bit of logic. Thanks Paul
Subject: Bug number PR28923 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00341.html
Subject: Bug 28923 Author: pault Date: Sun Sep 10 17:13:29 2006 New Revision: 116815 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116815 Log: 2006-09-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/28923 expr.c (find_array_section): Only use the array lower and upper bounds for the start and end of the sections, where the expr is NULL. 2006-09-10 Paul Thomas <pault@gcc.gnu.org> PR libfortran/28923 gfortran.dg/array_initializer_2.f90: Fill in missing index start value. gfortran.dg/array_initializer_3.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/array_initializer_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/array_initializer_2.f90
Subject: Bug 28923 Author: pault Date: Sun Sep 10 17:32:22 2006 New Revision: 116819 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116819 Log: 2006-09-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/28923 expr.c (find_array_section): Only use the array lower and upper bounds for the start and end of the sections, where the expr is NULL. PR fortran/28959 trans-types.c (gfc_get_derived_type): Use the parent namespace of the procedure if the type's own namespace does not have a parent. 2006-09-09 Paul Thomas <pault@gcc.gnu.org> PR libfortran/28947 * m4/matmul.m4: For the case where the second input argument is transposed, ensure that the case with rank (a) == 1 is correctly calculated. * generated/matmul_r4.c: Regenerate. * generated/matmul_r8.c: Regenerate. * generated/matmul_r10.c: Regenerate. * generated/matmul_r16.c: Regenerate. * generated/matmul_c4.c: Regenerate. * generated/matmul_c8.c: Regenerate. * generated/matmul_c10.c: Regenerate. * generated/matmul_c16.c: Regenerate. * generated/matmul_i4.c: Regenerate. * generated/matmul_i8.c: Regenerate. * generated/matmul_i16.c: Regenerate. 2006-09-09 Paul Thomas <pault@gcc.gnu.org> PR libfortran/28923 gfortran.dg/array_initializer_2.f90: Fill in missing index start value. gfortran.dg/array_initializer_3.f90: New test. PR libfortran/28947 gfortran.dg/matmul_4.f90: New test. PR fortran/28959 gfortran.dg/used_types_10: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/array_initializer_3.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/matmul_4.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_types_10.f90
Fixed on trunk and 4.1 Paul