Le 10/10/2026 à 21:57, Jerry DeLisle a écrit :
See attached patch. A DATA statement that initializes a pointer to an
array element, e.g. data p /t(3)/, segfaults in
gfc_conv_scalarized_array_ref. resolve_data resolves the variables of
a DATA statement but not its values, so t(3) is still an AR_UNKNOWN
reference when it reaches code generation, where it takes the
scalarized path with no scalarizer. The patch calls gfc_resolve_expr
on each value in resolve_data before the values are matched to the
variables.

The fix is in resolve_data in resolve.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: [PR125762] Fix segfault for DATA pointer init to an array element

Resolve the value expressions of a DATA statement in resolve_data.

Assisted-by: Claude Opus 5.5

        PR fortran/125762

gcc/fortran/ChangeLog:

        * resolve.cc (resolve_data): Call gfc_resolve_expr on each value
        expression.

gcc/testsuite/ChangeLog:

        * gfortran.dg/data_pointer_4.f90: New test.
OK.

Reply via email to