This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/50294] ICE in output_constructor_regular_field, at varasm.c:4751


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-05 14:06:57 UTC ---
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c        (revision 178527)
+++ gcc/varasm.c        (working copy)
@@ -4746,9 +4746,13 @@ output_constructor_regular_field (oc_loc

   if (local->index != NULL_TREE)
     {
+      /* Perform the index calculation in modulo arithmetic but
+         sign-extend the result because Ada has negative DECL_FIELD_OFFSETs
+        but we are using an unsigned sizetype.  */
+      unsigned prec = TYPE_PRECISION (sizetype);
       double_int idx = double_int_sub (tree_to_double_int (local->index),
                                       tree_to_double_int (local->min_index));
-      gcc_assert (double_int_fits_in_shwi_p (idx));
+      idx = double_int_sext (idx, prec);
       fieldpos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (local->val)), 1)
                  * idx.low);
     }

fixes this, but loses the check for index - min_index overflowing a HWI
(arguably that should have been detected earlier in the FEs).  Fact is
we lose information when forcing offsets / indices to an unsigned type.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]