https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49802
--- Comment #24 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:f99426a60b8f59b9b189efc0cff9047a47bda627 commit r17-3647-gf99426a60b8f59b9b189efc0cff9047a47bda627 Author: Jerry DeLisle <[email protected]> Date: Sun Aug 23 18:28:54 2026 -0700 fortran: [PR49802]-2 Allow VALUE on assumed-length CHARACTER dummies Fortran 2003 C528 prohibited the VALUE attribute on a CHARACTER dummy whose length is not one. Fortran 2008 relaxed this with C557, and F2023 Annex C.2 lists it as a Fortran 2008 feature that the Fortran 2008 Introduction did not mention. gfortran was still rejecting both an assumed length and a specified but non-constant length, such as another dummy argument used as the length. resolve.cc relaxes the constant-length requirement, gated by gfc_notify_std so that -std=f2003 still rejects it, and consolidates the C-interop length checks into a single "must have length one" condition ordered ahead of the Fortran 2008 allowance. trans-types.cc keeps such a dummy passed by reference, since VALUE now means copy-in-only semantics rather than pass-by-value of the raw data, and conv_dummy_value makes the caller-side copy. The copy size is scaled by the size of the character kind, so that a kind wider than one byte copies the whole string rather than its first bytes. PR fortran/49802 gcc/fortran/ChangeLog: * resolve.cc (resolve_symbol): Allow character(len=*) VALUE and a specified but non-constant length under Fortran 2008; consolidate the C-interop length checks into a single "must have length one" check ordered ahead of the Fortran 2008 allowance. * trans-expr.cc (conv_dummy_value): For assumed-length or non-constant-length CHARACTER VALUE dummies, make a caller-side copy and pass its address; scale the copy size by the size of the character kind. * trans-types.cc (gfc_sym_type): Use byref=1 for assumed-length or non-constant-length VALUE character dummies, so the ABI still passes by reference. gcc/testsuite/ChangeLog: * gfortran.dg/value_5.f90: Compile under -std=f2003 so the Fortran 2008 assumed-length VALUE relaxation is exercised as a rejection, and update the C-interop error expectation to match the consolidated diagnostic. * gfortran.dg/value_6.f90: New test. * gfortran.dg/value_7.f90: New test. * gfortran.dg/value_11.f90: New test. * gfortran.dg/value_14.f90: New test.
