------- Comment #6 from dominiq at lps dot ens dot fr 2009-04-27 08:20 ------- I think the right patch is:
--- ../_gcc_clean/gcc/fortran/trans-array.c 2009-04-20 13:44:15.000000000 +0200 +++ gcc/fortran/trans-array.c 2009-04-27 09:38:58.000000000 +0200 @@ -3253,6 +3253,8 @@ gfc_conv_ss_startstride (gfc_loopinfo * info->start[n]); tmp = fold_build2 (FLOOR_DIV_EXPR, gfc_array_index_type, tmp, info->stride[n]); + tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, + gfc_index_one_node, tmp); tmp = fold_build2 (MAX_EXPR, gfc_array_index_type, tmp, build_int_cst (gfc_array_index_type, 0)); /* We remember the size of the first section, and check all the Is a comment really needed? I have manually tested the failures seen with the patch in comment #3 and they all pass now except gfortran.dg/bounds_check_14.f90 which gives [ibook-dhum] f90/bug% gfc -fbounds-check /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/bounds_check_14.f90 [ibook-dhum] f90/bug% a.out At line 21 of file /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/bounds_check_14.f90 Fortran runtime error: Array bound mismatch, size mismatch for dimension 1 of array 'xca' (1/0) Line 21 is xca(1:1) = xda(1:2:mf3) and I think the diagnostic is now correct (mf3==-3 or -1) and I don't understand how the test is supposed to work: if size(xda(1:2:mf3)) == 0, as checked by a later test, how can xca take the value -1? What ma I missing? Also I'd be interested by ideas about test cases for this PR. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35732