[PATCH] fortran: [PR125720] ICE assigning an allocatable character to an allocatable component
Jerry DeLisle
jvdelisle2@gmail.com
Sat Oct 10 19:57:34 GMT 2026
See attached patch. A structure constructor that gives an explicit-length
allocatable character component an allocatable or deferred-length value
ICEs in fold_convert_loc. gfc_trans_subcomponent_assign falls through to
its final branch, which fold_converts the value, a pointer to the
string, to the component's character type. The patch copies the string
with gfc_trans_string_copy instead, which also truncates or blank-pads
it to the declared length.
The fix is the new BT_CHARACTER branch in gfc_trans_subcomponent_assign
in trans-expr.cc; the rest is the new test. The bug was found with the
Fujitsu compiler test suite; the test is new.
Regression tested on x86_64.
OK for mainline?
Regards,
Jerry
---
fortran: [PR125720] ICE assigning an allocatable character to an allocatable component
In a structure constructor, copy a value into an explicit-length
allocatable character component with gfc_trans_string_copy instead of
a scalar fold_convert.
Assisted-by: Claude Opus 5.5
PR fortran/125720
gcc/fortran/ChangeLog:
* trans-expr.cc (gfc_trans_subcomponent_assign): Use
gfc_trans_string_copy for an explicit-length allocatable
character component.
gcc/testsuite/ChangeLog:
* gfortran.dg/structure_constructor_19.f90: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR125720-alloc-char-scalar-component-ctor.patch
Type: text/x-patch
Size: 2973 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20261010/c7f26699/attachment.bin>
More information about the Gcc-patches
mailing list