From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26209 invoked by alias); 1 Mar 2014 18:16:53 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 26140 invoked by uid 48); 1 Mar 2014 18:16:47 -0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/60370] TRANSPOSE on rhs of allocatable array assignment gives error with -fcheck=bounds Date: Sat, 01 Mar 2014 18:16:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: diagnostic, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg00033.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60370 Mikael Morin changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mikael at gcc dot gnu.org --- Comment #3 from Mikael Morin --- 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. */