This was identified in comment #13 of PR34143 and is not fixed by the patch for that PR. The problem of conversion shows up even without -fdefault-integer-8 along with bound problems as shown by the following code: integer, parameter :: ik=4 type :: struct integer(4), allocatable :: ib(:) end type struct integer, parameter :: from=-1, to=2 integer(ik), allocatable :: ia(:) type(struct) :: x allocate(ia(from:to)) print *, 'bounds, full array ', lbound(ia), ubound(ia) print *, 'bounds, full implicit section', lbound(ia(:)), ubound(ia(:)) print *, 'bounds, full explicit section', lbound(ia(from:to)), ubound(ia(from:to)) print *, 'derived type, ik=', ik 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) deallocate(ia) end with ik = 4, the ouput is: bounds, full array -1 2 bounds, full implicit section 1 4 bounds, full explicit section 1 4 derived type, ik= 4 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 with ik = 8: ... derived type, ik= 8 bounds, full array 1 4 <--- should not it be -1 2 as for ik = 4? bounds, full implicit section 1 4 bounds, full explicit section 1 4
AFAICT this pr is the cause of half of the failures of gfortran.dg/alloc_comp_constructor_1.f90 on i686-apple-darwin9 with -fdefault-integer-8: FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O0 execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O0 scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O1 execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O1 scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O2 execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O2 scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -fomit-frame-pointer execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -fomit-frame-pointer scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -fomit-frame-pointer -funroll-loops execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -fomit-frame-pointer -funroll-loops scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -g execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -O3 -g scan-tree-dump-times original "builtin_free" 21 FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -Os execution test FAIL: gfortran.dg/alloc_comp_constructor_1.f90 -Os scan-tree-dump-times original "builtin_free" 21 The second half is due to 24 "builtin_free" in the "original" dump. This is the cause of some failures of this test on powerpc-apple-darwin9 (-O0/1, I have filled pr38347 against the middle-end for the ICE got with higher optimizations).
This is, of course, confirmed! Paul
patch http://gcc.gnu.org/ml/fortran/2009-01/msg00348.html The failure for ik=8 is not fixed by this patch. I thought it was ok because of the kind conversion function call. But it seems it's not. It is impacting function calls too (descriptor with wrong bounds passed), but the descriptor bounds are never used from within the function. This needs a bit more investigation.
I just, at last, posted a fix on the list. Paul
Subject: Bug 38324 Author: pault Date: Sun Jan 31 12:05:22 2010 New Revision: 156399 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156399 Log: 2010-01-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38324 * expr.c (gfc_get_full_arrayspec_from_expr): New function. * gfortran.h : Add prototype for above. * trans-expr.c (gfc_trans_alloc_subarray_assign): New function. (gfc_trans_subcomponent_assign): Call new function to replace the code to deal with allocatable components. * trans-intrinsic.c (gfc_conv_intrinsic_bound): Call gfc_get_full_arrayspec_from_expr to replace existing code. 2010-01-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38324 * gfortran.dg/alloc_comp_basics_1.f90: Remove option -O2. * gfortran.dg/alloc_comp_bounds_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/alloc_comp_bounds_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-intrinsic.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/alloc_comp_basics_1.f90
Subject: Bug 38324 Author: pault Date: Sun Jan 31 14:57:13 2010 New Revision: 156401 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156401 Log: 2010-01-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38324 * expr.c (gfc_get_full_arrayspec_from_expr): New function. * gfortran.h : Add prototype for above. * trans-expr.c (gfc_trans_alloc_subarray_assign): New function. (gfc_trans_subcomponent_assign): Call new function to replace the code to deal with allocatable components. * trans-intrinsic.c (gfc_conv_intrinsic_bound): Call gfc_get_full_arrayspec_from_expr to replace existing code. 2010-01-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38324 * gfortran.dg/alloc_comp_basics_1.f90: Remove option -O2. * gfortran.dg/alloc_comp_bounds_1.f90: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/alloc_comp_bounds_1.f90 Modified: branches/gcc-4_4-branch/gcc/fortran/ChangeLog branches/gcc-4_4-branch/gcc/fortran/expr.c branches/gcc-4_4-branch/gcc/fortran/gfortran.h branches/gcc-4_4-branch/gcc/fortran/trans-expr.c branches/gcc-4_4-branch/gcc/fortran/trans-intrinsic.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/alloc_comp_basics_1.f90
Fixed on trunk and 4.4 Paul