]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/30338 (infinite loop in maybe_canonicalize_comparison)
authorRichard Guenther <rguenther@suse.de>
Sun, 31 Dec 2006 14:01:19 +0000 (14:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sun, 31 Dec 2006 14:01:19 +0000 (14:01 +0000)
2006-12-31  Richard Guenther  <rguenther@suse.de>

PR middle-end/30338
* fold-const.c (fold_binary): Fix type-mismatch in folding
of -1 - A to ~A.

* gcc.c-torture/compile/pr30338.c: New testcase.

From-SVN: r120297

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr30338.c [new file with mode: 0644]

index ff58d77ab54b85839f2862c01ca913007bb52e7d..1e2601bac4913f66e378b9fc72cad8090fbc10c1 100644 (file)
@@ -1,3 +1,9 @@
+2006-12-31  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/30338
+       * fold-const.c (fold_binary): Fix type-mismatch in folding
+       of -1 - A to ~A.
+
 2006-12-30  Kazu Hirata  <kazu@codesourcery.com>
 
        * tree-inline.c: Fix a comment typo.
index 18746096b5a3cac28c3d2be43a583860b66f91c0..dbdc9c26367efee27f0a4315bc727ea265d257ba 100644 (file)
@@ -9009,7 +9009,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
       /* Convert -1 - A to ~A.  */
       if (INTEGRAL_TYPE_P (type)
          && integer_all_onesp (arg0))
-       return fold_build1 (BIT_NOT_EXPR, type, arg1);
+       return fold_build1 (BIT_NOT_EXPR, type, op1);
 
       if (! FLOAT_TYPE_P (type))
        {
index 564312da9348c3e5ce35293264367c1404dd7118..a24138920b200b36e233b40450bdaba17b926f4b 100644 (file)
@@ -1,3 +1,8 @@
+2006-12-31  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/30338
+       * gcc.c-torture/compile/pr30338.c: New testcase.
+
 2006-12-31  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/27900
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr30338.c b/gcc/testsuite/gcc.c-torture/compile/pr30338.c
new file mode 100644 (file)
index 0000000..2d6245d
--- /dev/null
@@ -0,0 +1,14 @@
+/* We used to do folding with mismatched types which caused us to
+   infinitely loop in comparison foldings.  */
+
+extern char *grub_scratch_mem;
+int testload_func (char *arg, int flags)
+{
+  int i;
+  for (i = 0; i < 0x10ac0; i++)
+    if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem)))
+        != *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem))))
+      return 0;
+  return 1;
+}
+