http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60370
Mikael Morin <mikael at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikael at gcc dot gnu.org --- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> --- The array reallocation code must come before the bound checking code, but after the loop bounds evaluation code. However, at the time of reallocation generation the two last codes have already been put in one single block. The following doesn't work because the array reallocation code uses the loop bounds so reallocation can't come before loop bounds evaluation. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 1e156ff..00b1459 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -8044,7 +8044,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, ompws_flags &= ~OMPWS_SCALARIZER_WS; tmp = gfc_alloc_allocatable_for_assignment (&loop, expr1, expr2); if (tmp != NULL_TREE) - gfc_add_expr_to_block (&loop.code[expr1->rank - 1], tmp); + gfc_prepend_expr_to_block (&loop.pre, tmp); } /* Generate the copying loops. */