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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Harald Anlauf
<anl...@gcc.gnu.org>:

https://gcc.gnu.org/g:2ebf3af1f84d54fbda172eff105a8842c685d11d

commit r13-8793-g2ebf3af1f84d54fbda172eff105a8842c685d11d
Author: Andrew Jenner <and...@codesourcery.com>
Date:   Tue Nov 28 15:27:05 2023 +0000

    Fortran: fix reallocation on assignment of polymorphic variables [PR110415]

    This patch fixes two bugs related to polymorphic class assignment in the
    Fortran front-end. One (described in PR110415) is an issue with the malloc
    and realloc calls using the size from the old vptr rather than the new one.
    The other is caused by the return value from the realloc call being
ignored.
    Testcases are added for these issues.

    2023-11-28  Andrew Jenner  <and...@codesourcery.com>

    gcc/fortran/
            PR fortran/110415
            * trans-expr.cc (trans_class_vptr_len_assignment): Add
            from_vptrp parameter. Populate it. Don't check for DECL_P
            when deciding whether to create temporary.
            (trans_class_pointer_fcn, gfc_trans_pointer_assignment): Add
            NULL argument to trans_class_vptr_len_assignment calls.
            (trans_class_assignment): Get rhs_vptr from
            trans_class_vptr_len_assignment and use it for determining size
            for allocation/reallocation. Use return value from realloc.

    gcc/testsuite/
            PR fortran/110415
            * gfortran.dg/pr110415.f90: New test.
            * gfortran.dg/asan/pr110415-2.f90: New test.
            * gfortran.dg/asan/pr110415-3.f90: New test.

    Co-Authored-By: Tobias Burnus  <tob...@codesourcery.com>
    (cherry picked from commit b247e917ff13328298c1eecf8563b12edd7ade04)

Reply via email to