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

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

https://gcc.gnu.org/g:48024a99e3c2ae522d0026eedd591390506b68ca

commit r14-9996-g48024a99e3c2ae522d0026eedd591390506b68ca
Author: Harald Anlauf <anl...@gmx.de>
Date:   Sat Apr 13 19:09:24 2024 +0200

    Fortran: ALLOCATE of fixed-length CHARACTER with SOURCE/MOLD [PR113793]

    F2008 requires for ALLOCATE with SOURCE= or MOLD= specifier that the kind
    type parameters of allocate-object and source-expr have the same values.
    Add compile-time diagnostics for different character length and a runtime
    check (under -fcheck=bounds).  Use length from allocate-object to prevent
    heap corruption and to allow string padding or truncation on assignment.

    gcc/fortran/ChangeLog:

            PR fortran/113793
            * resolve.cc (resolve_allocate_expr): Reject ALLOCATE with SOURCE=
            or MOLD= specifier for unequal length.
            * trans-stmt.cc (gfc_trans_allocate): If an allocatable character
            variable has fixed length, use it and do not use the source length.
            With bounds-checking enabled, add a runtime check for same length.

    gcc/testsuite/ChangeLog:

            PR fortran/113793
            * gfortran.dg/allocate_with_source_29.f90: New test.
            * gfortran.dg/allocate_with_source_30.f90: New test.
            * gfortran.dg/allocate_with_source_31.f90: New test.

Reply via email to