2006-08-26 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Aug 2006 22:01:28 +0000 (22:01 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 25 Aug 2006 22:01:28 +0000 (22:01 +0000)
PR middle-end/28814
* fold-const.c (fold_binary): Fold temporary to correct
type before constructing new comparison.

* gcc.dg/torture/pr28814.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116439 138bc75d-0d04-0410-961f-82ee72b054a4

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

index b56d210..c18b80e 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-26  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28814
+       * fold-const.c (fold_binary): Fold temporary to correct
+       type before constructing new comparison.
+
 2006-08-25  Fariborz Jahanian  <fjahanian@apple.com>
 
        PR c/28418
index 277bd32..69db6c2 100644 (file)
@@ -10289,7 +10289,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
          && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
          && 0 != (tem = const_binop (TREE_CODE (arg0) == PLUS_EXPR
                                      ? MINUS_EXPR : PLUS_EXPR,
-                                     arg1, TREE_OPERAND (arg0, 1), 0))
+                                     fold_convert (TREE_TYPE (arg0), arg1),
+                                     TREE_OPERAND (arg0, 1), 0))
          && ! TREE_CONSTANT_OVERFLOW (tem))
        return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem);
 
index 9965dd5..9194e7f 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-26  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28814
+       * gcc.dg/torture/pr28814.c: New testcase.
+
 2006-08-25  Joseph S. Myers  <joseph@codesourcery.com>
 
        PR c/28418
diff --git a/gcc/testsuite/gcc.dg/torture/pr28814.c b/gcc/testsuite/gcc.dg/torture/pr28814.c
new file mode 100644 (file)
index 0000000..94bbc74
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+struct w49
+{
+  union
+  {
+  }
+  value;
+};
+f9887 (struct w49 a23040)
+{
+  unsigned long r9887;
+  if (((struct structure_type24753 *) (r9887 - 1)) == ((void *) 0))
+    {
+      backtrace ("stalin.sc", 7222, 248274);
+    }
+}