https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57562

--- Comment #5 from janus at gcc dot gnu.org ---
This patch fixes the ICE on comment 4, but not on comment 0, and regtests
cleanly:


Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c    (Revision 219126)
+++ gcc/fortran/expr.c    (Arbeitskopie)
@@ -1278,8 +1278,15 @@ find_component_ref (gfc_constructor_base base, gfc
   pick = ref->u.c.component;
   while (comp != pick)
     {
-      comp = comp->next;
-      c = gfc_constructor_next (c);
+      if (comp->next)
+      {
+    comp = comp->next;
+    c = gfc_constructor_next (c);
+      }
+      else if (comp->ts.type == BT_DERIVED)
+    comp = comp->ts.u.derived->components;
+      else
+    gcc_unreachable();
     }

   return c;

Reply via email to