https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107508

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <bur...@gcc.gnu.org>:

https://gcc.gnu.org/g:071d00e0faabbd45449d2e83f207fca0f8e8ef68

commit r13-3751-g071d00e0faabbd45449d2e83f207fca0f8e8ef68
Author: Tobias Burnus <tob...@codesourcery.com>
Date:   Mon Nov 7 11:32:33 2022 +0100

    Fortran: Fix reallocation on assignment for kind=4 strings [PR107508]

    The check whether reallocation on assignment was required did not handle
    kind=4 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): Extend
            comment; minor cleanup.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/widechar_11.f90: New test.

Reply via email to