From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0A8C53858C50; Sun, 24 Apr 2022 16:54:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A8C53858C50 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104228] [9/10/11 Regression] ICE in df_install_ref, at df-scan.cc:2294 since r8-3589-g707905d0773e5a8e Date: Sun, 24 Apr 2022 16:54:45 +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: ice-on-invalid-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: P4 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: Sun, 24 Apr 2022 16:54:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104228 --- Comment #12 from CVS Commits --- The releases/gcc-10 branch has been updated by Mikael Morin : https://gcc.gnu.org/g:4c8e037d32e91c0ec4ac577d1d0723ab9d6ec809 commit r10-10554-g4c8e037d32e91c0ec4ac577d1d0723ab9d6ec809 Author: Mikael Morin Date: Fri Jan 28 22:00:57 2022 +0100 fortran: Backport associate character length fixes [PR104228] Backport commits: r12-7217-g57da34939703a6e6d3267a0d25d1fb9369d3ac0e r12-7726-g907811ddc35da6c1701ed22355ece63a8c3ed7fb -- fortran: Unshare associate var charlen [PR104228] PR104228 showed that character lengths were shared between associate variable and associate targets. This is problematic when the associate target is itself a variable and gets a variable to hold the length, as the length variable is added (and all the variables following it in the chain) to both the associate variable scope and the target variable scope. This caused an ICE when compiling with -O0 -fsanitize=3Daddress. This change forces the creation of a separate character length for the associate variable. It also forces the initialization of the character length variable to avoid regressing associate_32 and associate_47 tests. -- fortran: Separate associate character lengths earlier [PR104570] This change workarounds an ICE in the evaluation of the character length of an array expression referencing an associate variable; the code is not prepared to see a non-scalar expression as it doesn=C3=A2t initiali= ze the scalarizer. Before this change, associate length symbols get a new gfc_charlen at resolution stage to unshare them from the associate expression, so that at translation stage it is a decl specific to the associate symbol that is initialized, not the decl of some other symbol. This reinitialization of gfc_charlen happens after expressions referencing the associate symbol have been parsed, so that those expressions retain the original gfc_charlen they have copied from the symbol. At translation stage, the gfc_charlen for the associate symbol is setup with the decl holding the actual length value, but the expressions have retained the original gfc_charlen without any decl. So they need to evaluate the character length, and this is where the ICE happens. This change moves the reinitialization of gfc_charlen earlier at parsing stage, so that at resolution stage the gfc_charlen can be retained as it=C3=A2s already not shared with any other symbol, and the expressions= which now share their gfc_charlen with the symbol are automatically updated when the length decl is setup at translation stage. There is no need any more to evaluate the character length as it has all the required information, and the ICE doesn=C3=A2t happen. The first resolve.c hunk is necessary to avoid regressing on the associate_35.f90 testcase. -- PR fortran/104228 PR fortran/104570 gcc/fortran/ChangeLog: * parse.c (parse_associate): Use a new distinct gfc_charlen if the copied type has one whose length is not known to be constant. * resolve.c (resolve_assoc_var): Also create a new character length for non-dummy associate targets. Reset charlen if it=C3= =A2s shared with the associate target regardless of the expression type. Don=C3=A2t reinitialize charlen if it=C3=A2s deferred. * trans-stmt.c (trans_associate_var): Initialize character length even if no temporary is used for the associate variable. gcc/testsuite/ChangeLog: * gfortran.dg/asan_associate_58.f90: New test. * gfortran.dg/asan_associate_59.f90: New test. * gfortran.dg/associate_58.f90: New test.=