From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32100 invoked by alias); 25 May 2014 12:28:56 -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 32060 invoked by uid 48); 25 May 2014 12:28:52 -0000 From: "mikael at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/61138] [4.8/4.9/4.10 Regression] Wrong code with pointer-bounds remapping Date: Sun, 25 May 2014 12:28: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.10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mikael at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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-05/txt/msg02150.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61138 --- Comment #4 from Mikael Morin --- (In reply to Mikael Morin from comment #2) > gfc_trans_pointer_assignment sets lse.descriptor_only before calling > gfc_conv_expr_descriptor (for the lhs), and later on reuses lse for other > things, without clearing descriptor_only. The proper fix would avoid reusing any gfc_se struct entirely; a more humble, ad hoc fix could look like this: diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 5a50122..9748ade 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6684,2 +6684,3 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2) lse.expr = tmp; + lse.descriptor_only = 0; lse.direct_byref = 1; @@ -6699,2 +6700,3 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2) lse.direct_byref = 1; + lse.descriptor_only = 0; gfc_conv_expr_descriptor (&lse, expr2); @@ -6750,2 +6752,3 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2) lse.direct_byref = 1; + lse.descriptor_only = 0; gfc_conv_expr_descriptor (&lse, expr2);