------- Comment #3 from dominiq at lps dot ens dot fr 2009-04-26 21:32 ------- The following patch seems to fix the PR (not fully tested yet):
--- ../_gcc_clean/gcc/fortran/trans-array.c 2009-04-20 13:44:15.000000000 +0200 +++ gcc/fortran/trans-array.c 2009-04-26 23:24:12.000000000 +0200 @@ -3249,8 +3249,10 @@ gfc_conv_ss_startstride (gfc_loopinfo * } /* Check the section sizes match. */ - tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, end, - info->start[n]); + tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, + gfc_index_one_node, info->start[n]); + tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type, + end, tmp); tmp = fold_build2 (FLOOR_DIV_EXPR, gfc_array_index_type, tmp, info->stride[n]); tmp = fold_build2 (MAX_EXPR, gfc_array_index_type, tmp, One thing I don't understand is why "fold_convert (long_integer_type_node, size[n])" is magically updated. With the patch I get: [ibook-dhum] f90/bug% gfc -fcheck=all pr35732.f90 [ibook-dhum] f90/bug% a.out At line 4 of file pr35732.f90 Fortran runtime error: Array bound mismatch, size mismatch for dimension 1 of array 'a' (1/2) [ibook-dhum] f90/bug% gfc -fcheck=all pr39872.f90 [ibook-dhum] f90/bug% a.out At line 7 of file pr39872.f90 Fortran runtime error: Array bound mismatch, size mismatch for dimension 1 of array 'a' (4/5) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35732