re PR middle-end/65680 (ICE at -O1 and above on x86_64-linux-gnu in expand_assignment...
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2015 14:34:06 +0000 (16:34 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 7 Apr 2015 14:34:06 +0000 (16:34 +0200)
PR middle-end/65680
* expr.c (get_inner_reference): Handle bit_offset that doesn't fit
into signed HOST_WIDE_INT the same as negative bit_offset.

* gcc.c-torture/compile/pr65680.c: New test.

From-SVN: r221899

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr65680.c [new file with mode: 0644]

index 7b977dd8933e23e7d410923abd995d2b20c785ce..dcb7e99bd7f5e12f76e05e84130ad102c267aafe 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/65680
+       * expr.c (get_inner_reference): Handle bit_offset that doesn't fit
+       into signed HOST_WIDE_INT the same as negative bit_offset.
+
 2015-04-07  Ilya Enkovich  <ilya.enkovich@intel.com>
 
        * ipa-comdats.c (ipa_comdats): Visit all thunks
index dc13a14f4e7860a08612d855e2b84804dda5ab7e..5c095507f4a303b1c4ab3519d165735be5a37d07 100644 (file)
@@ -6941,7 +6941,7 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
   if (offset)
     {
       /* Avoid returning a negative bitpos as this may wreak havoc later.  */
-      if (wi::neg_p (bit_offset))
+      if (wi::neg_p (bit_offset) || !wi::fits_shwi_p (bit_offset))
         {
          offset_int mask = wi::mask <offset_int> (LOG2_BITS_PER_UNIT, false);
          offset_int tem = bit_offset.and_not (mask);
index 34d12535e0285b5fa7b5e9fb4cded8221ec053ee..933da2cac14e5bd6bdf3c62619ffc32381589beb 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/65680
+       * gcc.c-torture/compile/pr65680.c: New test.
+
 2015-04-07  Andre Vehreschild  <vehre@gmx.de>
 
        PR fortran/65548
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65680.c b/gcc/testsuite/gcc.c-torture/compile/pr65680.c
new file mode 100644 (file)
index 0000000..02f08ce
--- /dev/null
@@ -0,0 +1,20 @@
+/* PR middle-end/65680 */
+/* { dg-do compile { target lp64 } } */
+
+struct S
+{
+  int f : 1;
+} a[100000000000000001][3];
+
+void
+foo (void)
+{
+  struct S b = { 0 };
+  a[100000000000000000][0] = b;
+}
+
+void
+bar (void)
+{
+  a[100000000000000000][0].f = 1;
+}