$ uname -a Linux localhost.localdomain 2.6.29.4-167.fc11.i686.PAE #1 SMP Wed May 27 17:28:22 EDT 2009 i686 i686 i386 GNU/Linux $ /usr/local/gfortran/bin/gfortran --version GNU Fortran (GCC) 4.5.0 20091205 (experimental) [trunk revision 155016] $ cat x.f95 PROGRAM X TYPE T INTEGER :: I END TYPE T TYPE(T), TARGET :: T1(3) INTEGER, POINTER :: P(:) T1(1)%I = 1 T1(2)%I = 2 T1(3)%I = 3 P => T1%I CALL Z(P) PRINT *, T1%I CONTAINS SUBROUTINE Z(Q) INTEGER, POINTER :: Q(:) Q(1) = 999 END SUBROUTINE Z END PROGRAM X $ /usr/local/gfortran/bin/gfortran -o x x.f95 $ ./x 1 999 3 !! The output is wrong. I am expecting this output: 999 2 3
using Q(0) puts the 999 in the first position. We have an off by one error here.
I think that I know how to fix this one, so am assigning myself. I would regard this as a "serious" bug. Paul
I am not at all happy with designating this bug a regression. This worked with 4.1 and 4.2 because the stride measure for the derived type was the same as an integer; add more components and see what happens.... I am at that stage, where I can fix the testcase but other things break :-) Watch this space. This is another bug, where the array descriptor reform will afford a permanent fix. If I do not see a quick fix soon, I will concentrate on array descriptors. Paul
Paul's patch: http://gcc.gnu.org/ml/fortran/2010-02/msg00019.html
Subject: Bug 42309 Author: pault Date: Fri Feb 5 05:28:37 2010 New Revision: 156512 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156512 Log: 2010-02-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/42309 * trans-expr.c (gfc_conv_subref_array_arg): Add new argument 'formal_ptr'. If this is true, give returned descriptor unity lbounds, in all dimensions, and the appropriate offset. (gfc_conv_procedure_call); If formal is a pointer, set the last argument of gfc_conv_subref_array_arg to true. * trans.h : Add last argument for gfc_conv_subref_array_arg. * trans-io.c (set_internal_unit, gfc_trans_transfer): Set the new arg of gfc_conv_subref_array_arg to false. * trans-stmt.c (forall_make_variable_temp): The same. 2010-02-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/42309 * gfortran.dg/subref_array_pointer_4.f90 : New test. Added: trunk/gcc/testsuite/gfortran.dg/subref_array_pointer_4.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-io.c trunk/gcc/fortran/trans-stmt.c trunk/gcc/fortran/trans.h trunk/gcc/testsuite/ChangeLog
Subject: Bug 42309 Author: pault Date: Sat Feb 6 19:44:41 2010 New Revision: 156554 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156554 Log: 2010-02-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/42309 * trans-expr.c (gfc_conv_subref_array_arg): Add new argument 'formal_ptr'. If this is true, give returned descriptor unity lbounds, in all dimensions, and the appropriate offset. (gfc_conv_procedure_call); If formal is a pointer, set the last argument of gfc_conv_subref_array_arg to true. * trans.h : Add last argument for gfc_conv_subref_array_arg. * trans-io.c (set_internal_unit, gfc_trans_transfer): Set the new arg of gfc_conv_subref_array_arg to false. * trans-stmt.c (forall_make_variable_temp): The same. 2010-02-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/42309 * gfortran.dg/subref_array_pointer_4.f90 : New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/subref_array_pointer_4.f90 Modified: branches/gcc-4_4-branch/gcc/fortran/ChangeLog branches/gcc-4_4-branch/gcc/fortran/trans-expr.c branches/gcc-4_4-branch/gcc/fortran/trans-io.c branches/gcc-4_4-branch/gcc/fortran/trans-stmt.c branches/gcc-4_4-branch/gcc/fortran/trans.h branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 4.4. Many thanks for the report! Paul
On Linux/x86-64, gcc 4.4 at revision 156554 gave Executing on host: /export/gnu/import/svn/gcc-test/bld/gcc/testsuite/gfortran/../../gfortran -B/export/gnu/import/svn/gcc-test/bld/gcc/testsuite/gfortran/../../ /export/gnu/import/svn/gcc-test/src-4.4/gcc/testsuite/gfortran.dg/subref_array_pointer_2.f90 -O3 -g -pedantic-errors -B/export/gnu/import/svn/gcc-test/bld/x86_64-unknown-linux-gnu/32/libgfortran/.libs -L/export/gnu/import/svn/gcc-test/bld/x86_64-unknown-linux-gnu/32/libgfortran/.libs -L/export/gnu/import/svn/gcc-test/bld/x86_64-unknown-linux-gnu/32/libgfortran/.libs -L/export/gnu/import/svn/gcc-test/bld/x86_64-unknown-linux-gnu/32/libiberty -lm -m32 -o ./subref_array_pointer_2.exe (timeout = 300) /export/gnu/import/svn/gcc-test/src-4.4/gcc/testsuite/gfortran.dg/subref_array_pointer_2.f90: In function 'MAIN__':^M /export/gnu/import/svn/gcc-test/src-4.4/gcc/testsuite/gfortran.dg/subref_array_pointer_2.f90:49: internal compiler error: in fold_binary, at fold-const.c:9704^M Please submit a full bug report,^M with preprocessed source if appropriate.^M See <http://gcc.gnu.org/bugs.html> for instructions.^M
Regarding 4.4: It fails here (x86-64) for any option for: IF (ANY (T1%I .NE. [999, 2, 999, 4])) CALL ABORT as the result is: [1, 999, 3, 999]. (The other check succeeds.)
Patch for 4.4 and the 4.5-trunk by Jakub: http://gcc.gnu.org/ml/fortran/2010-02/msg00063.html
Subject: Bug 42309 Author: jakub Date: Wed Feb 10 15:10:53 2010 New Revision: 156659 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156659 Log: PR fortran/42309 * trans-expr.c (gfc_conv_subref_array_arg): Avoid accessing info->dimen after info has been freed. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-expr.c
Subject: Bug 42309 Author: jakub Date: Wed Feb 10 15:11:30 2010 New Revision: 156660 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156660 Log: PR fortran/42309 * trans-expr.c (gfc_conv_subref_array_arg): Avoid accessing info->dimen after info has been freed. Modified: branches/gcc-4_4-branch/gcc/fortran/ChangeLog branches/gcc-4_4-branch/gcc/fortran/trans-expr.c
Fixed.