From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 868BA3856250; Fri, 22 Apr 2022 20:53:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 868BA3856250 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102043] [9/10/11/12 Regression] Wrong array types used for negative stride accesses, gfortran.dg/vector_subscript_1.f90 FAILs Date: Fri, 22 Apr 2022 20:53:26 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mikael at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2022 20:53:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102043 --- Comment #44 from CVS Commits --- The master branch has been updated by Mikael Morin : https://gcc.gnu.org/g:89ca0fffa48b799b228beee48a16e26e24d8e199 commit r12-8227-g89ca0fffa48b799b228beee48a16e26e24d8e199 Author: Mikael Morin Date: Fri Apr 22 22:52:12 2022 +0200 fortran: Pre-evaluate string pointers. [PR102043] This avoids a regression on deferred_character_23.f90 later in the patch series when array references are rewritten to use pointer arithmetic. The problem is a SAVE_EXPR tree as TYPE_SIZE_UNIT of one array element type, which is used by the pointer arithmetic expressions. As these expressions appear in both branches of an if-then-else block, the tree is lowered to a variable in one of the branches but it=C3=A2s used in b= oth branches, which is invalid middle-end code. This change pre-evaluates the array references or pointer arithmetics to variables before the if-then-else block, so that the SAVE_EXPR are expanded to variables in the parent scope of the if-then-else block, and expressions referencing the variables remain valid in both branches. PR fortran/102043 gcc/fortran/ChangeLog: * trans-expr.cc: Pre-evaluate src and dest to variables before using them. gcc/testsuite/ChangeLog: * gfortran.dg/dependency_49.f90: Update variable occurence count.=