re PR middle-end/28814 (in compare_values, at tree-vrp.c:415)
authorRichard Guenther <rguenther@suse.de>
Fri, 25 Aug 2006 22:01:28 +0000 (22:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 25 Aug 2006 22:01:28 +0000 (22:01 +0000)
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.

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

From-SVN: r116439

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

index b56d2102577c899224dd74d363568e7fd9e546d7..c18b80e375ea395f756b51a861c32a2adee0e55f 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 277bd324d8d56c5382803b09e90fdca0fa189c9d..69db6c2613a3d0c504c722fc520eaaf62c1ca198 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 9965dd5c338de272cf1e8b23377185bd3a4b02eb..9194e7fb2a5f42cd90a8222e2f6a4e233319f0c4 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);
+    }
+}