[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762 --- Comment #6 from Mikael Morin --- (In reply to Jerry DeLisle from comment #5) > Created attachment 64791 [details] > Patch with a better approach > > Regression tested OK I still find it unbelievable the compiler has been working with non-resolved expressions for so long, but looks good. OK to push with the real PR number in the testcase and a suitable ChangeLog entry.
[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762 Jerry DeLisle changed: What|Removed |Added Attachment #64775|0 |1 is obsolete|| --- Comment #5 from Jerry DeLisle --- Created attachment 64791 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64791&action=edit Patch with a better approach Regression tested OK
[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762
--- Comment #4 from Jerry DeLisle ---
The new fix:
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 57561e8686f..526755fef42 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -19787,10 +19787,15 @@ resolve_data_variables (gfc_data_variable *d)
static void
resolve_data (gfc_data *d)
{
+ gfc_data_value *v;
if (!resolve_data_variables (d->var))
return;
+ for (v = d->value; v; v = v->next)
+if (v->expr && !gfc_resolve_expr (v->expr))
+ return;
+
values.vnode = d->value;
if (d->value == NULL)
mpz_set_ui (values.left, 0);
[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762 --- Comment #3 from Jerry DeLisle --- (In reply to Mikael Morin from comment #2) > How is it possible the array ref remains AR_UNKNOWN? > resolve_data_variables should call gfc_resolve_expr on every value. Very good point. Its related to the ordering of gfc_resolve_values and gfc_resolve_data. The resolve_values runs before resolve_data in the same pass. So when resolve_values traverses the namespace, p1->value is still NULL. Then resolve_data stores the unresolved t(3) (with AR_UNKNOWN) into p1->value — and resolve_values never runs again. I am testing a different patch.
[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762 Mikael Morin changed: What|Removed |Added CC||mikael at gcc dot gnu.org --- Comment #2 from Mikael Morin --- How is it possible the array ref remains AR_UNKNOWN? resolve_data_variables should call gfc_resolve_expr on every value.
[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762 Jerry DeLisle changed: What|Removed |Added CC||jvdelisle2 at gmail dot com --- Comment #1 from Jerry DeLisle --- Created attachment 64775 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64775&action=edit Proposed patch
[Bug fortran/125762] Segfault in gfc_conv_scalarized_array_ref for a DATA statement
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125762 Jerry DeLisle changed: What|Removed |Added Last reconfirmed||2026-06-12 Assignee|unassigned at gcc dot gnu.org |jvdelisle at gcc dot gnu.org Status|UNCONFIRMED |NEW Ever confirmed|0 |1
