re PR sanitizer/81505 (ICE in tree-ssa-loop-manip.c:95 with -fsanitize=signed-integer...
authorRichard Biener <rguenther@suse.de>
Tue, 25 Jul 2017 07:04:07 +0000 (07:04 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 25 Jul 2017 07:04:07 +0000 (07:04 +0000)
2017-07-25  Richard Biener  <rguenther@suse.de>

PR middle-end/81505
* fold-const.c (fold_negate_const): TREE_OVERFLOW should be
sticky.

* gcc.dg/ubsan/pr81505.c: New testcase.

From-SVN: r250494

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ubsan/pr81505.c [new file with mode: 0644]

index f7b6e895dde7058ece1867008438ecf53291d6c0..54d6c5438ff63d7c5e0d9cb7d609d8aa38baccc6 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-25  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/81505
+       * fold-const.c (fold_negate_const): TREE_OVERFLOW should be
+       sticky.
+
 2017-07-24  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        * config/rs6000/rs6000-cpus.def (ISA_2_6_MASKS_SERVER): Delete
index c061f3e2f89264e28fc40080ef46f1f88af5e0aa..ecba3ffada493c7c390d280114ad41eef483d753 100644 (file)
@@ -13702,8 +13702,8 @@ fold_negate_const (tree arg0, tree type)
        bool overflow;
        wide_int val = wi::neg (arg0, &overflow);
        t = force_fit_type (type, val, 1,
-                           (overflow | TREE_OVERFLOW (arg0))
-                           && !TYPE_UNSIGNED (type));
+                           (overflow && ! TYPE_UNSIGNED (type))
+                           || TREE_OVERFLOW (arg0));
        break;
       }
 
index 07d7897821e5c6c8065b4fe1b9219eaca4b5909f..82119f104dd2c1e1a6ce2f1c5233f064aefd0754 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-25  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/81505
+       * gcc.dg/ubsan/pr81505.c: New testcase.
+
 2017-07-24  Daniel Santos  <daniel.santos@pobox.com>
 
        PR testsuite/80759
diff --git a/gcc/testsuite/gcc.dg/ubsan/pr81505.c b/gcc/testsuite/gcc.dg/ubsan/pr81505.c
new file mode 100644 (file)
index 0000000..1cebef5
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fsanitize=signed-integer-overflow" } */
+
+int a, b, c, h;
+
+int i[5][5];
+
+void
+fn1 ()
+{
+  int l = 0;
+
+  for (a = 0; a <= 3; a++)
+    for (b = 1; b >= 0; b -= 1)
+      l |= i[0][b];
+  c = l;
+}