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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:04e98c053c2b6734923e79f057f7e1a36d5446fa

commit r17-6328-g04e98c053c2b6734923e79f057f7e1a36d5446fa
Author: Jerry DeLisle <[email protected]>
Date:   Sat Nov 14 19:05:06 2026 -0800

    fortran: [PR128736] Heap overflow assigning CLASS array to TYPE array

    When a CLASS array was assigned to an allocatable array of its declared
    type, reallocation on assignment sized each element of the variable as
    the class container instead of the declared type.  A type larger than
    the container overflowed the new array, and a smaller one was
    over-allocated and given the wrong span.  Take the element size from the
    declared type of the CLASS expression.

    Assisted-by: Claude Opus 5.5

            PR fortran/128736

    gcc/fortran/ChangeLog:

            * trans-array.cc (gfc_alloc_allocatable_for_assignment): Take the
            element size of a variable that is not polymorphic from the
declared
            type of a polymorphic expression.

    gcc/testsuite/ChangeLog:

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

Reply via email to