From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2DDAE3858C2D; Mon, 7 Nov 2022 10:33:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DDAE3858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667817201; bh=JBo5U/ElZpdYnaLVpUwf0bTPK2OHvcsiWRo4ExqCz3I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MCHiHbZAc3EC5a5ZbTQFL+VId7sk6hsLeDjMw72vztqk91IbKu6o4yW4YT0Itvly7 KRNGyphgP7tGBOvZ86gy2hPNI7+UZFTuccTGGR83eiNAiWg/AbyMoj7mocRRTKG75s wF84fCLoy3Lb2few+YhTLNfVJe1h9kV9Gm2SCRac= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107508] Invalid bounds due to bogus reallocation on assignment with KIND=4 characters Date: Mon, 07 Nov 2022 10:33:19 +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: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107508 --- Comment #1 from CVS Commits --- The master branch has been updated by Tobias Burnus : https://gcc.gnu.org/g:071d00e0faabbd45449d2e83f207fca0f8e8ef68 commit r13-3751-g071d00e0faabbd45449d2e83f207fca0f8e8ef68 Author: Tobias Burnus Date: Mon Nov 7 11:32:33 2022 +0100 Fortran: Fix reallocation on assignment for kind=3D4 strings [PR107508] The check whether reallocation on assignment was required did not handle kind=3D4 characters correctly such that there was always a reallocation, implying issues with pointer addresses and lower bounds. Additionally, with all deferred strings, the old memory was not freed on reallocation. And, finally, inside the block which was only executed if string lengths or bounds or dynamic types changed, was a subcheck of the same, which was effectively a no op but still confusing and at least added with -O0 extra instructions to the binary. PR fortran/107508 gcc/fortran/ChangeLog: * trans-array.cc (gfc_alloc_allocatable_for_assignment): Fix string-length check, plug memory leak, and avoid generation of effectively no-op code. * trans-expr.cc (alloc_scalar_allocatable_for_assignment): Exte= nd comment; minor cleanup. gcc/testsuite/ChangeLog: * gfortran.dg/widechar_11.f90: New test.=