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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
We could either just punt in that case:
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -1112,12 +1112,15 @@ ctor_ref_range::accumulate_range_from_component_ref
(tree init, unsigned i,
 {
   unsigned ix;
   tree index, val;
-  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), ix, index, val)
-    {
-      if (index != fld)
-       continue;
-      return accumulate_range (val, i);
-    }
+  if (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == DECL_CONTEXT (fld))
+    FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), ix, index, val)
+      {
+       if (index != fld)
+         continue;
+       return accumulate_range (val, i);
+      }
+  else
+    return false;
   if (TREE_CODE (TREE_TYPE (init)) == RECORD_TYPE)
     {
       accumulate_range_from_missing_constructor_elt ();
or handle it, similarly like e.g. fold_const_aggregate_ref_1 handles it, i.e.
based on field offsets and sizes rather than FIELD_DECL equality.

Reply via email to