aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2024-04-13 19:09:24 +0200
committerHarald Anlauf <anlauf@gmx.de>2024-04-16 18:40:56 +0200
commit48024a99e3c2ae522d0026eedd591390506b68ca (patch)
treec923acf0e16dd5dd684fae7ae85f086b183cc540 /libcpp
parent443748259d903b6f4d4557392fc788df93d63377 (diff)
downloadgcc-48024a99e3c2ae522d0026eedd591390506b68ca.zip
gcc-48024a99e3c2ae522d0026eedd591390506b68ca.tar.gz
gcc-48024a99e3c2ae522d0026eedd591390506b68ca.tar.bz2
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.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions