re PR debug/32563 (ICE on pointer arithmetic)
authorRichard Guenther <rguenther@suse.de>
Wed, 22 Aug 2007 08:00:55 +0000 (08:00 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 22 Aug 2007 08:00:55 +0000 (08:00 +0000)
2007-08-22  Richard Guenther  <rguenther@suse.de>

PR middle-end/32563
* tree.c (host_integerp): Treat sizetype as signed as it is
sign-extended.

* g++.dg/torture/pr32563.C: New testcase.

From-SVN: r127688

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr32563.C [new file with mode: 0644]
gcc/tree.c

index 486b3d0fefb50720bac97e444e1c64b467c25ac5..234bc4505f5984e23363bd751cb2e0ca0532cffd 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-22  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/32563
+       * tree.c (host_integerp): Treat sizetype as signed as it is
+       sign-extended.
+
 2007-08-21  Ian Lance Taylor  <iant@google.com>
 
        PR tree-optimization/33134
index fb5aa87b06240db7f2363189108078633bf5aa2c..8b73a028977c07e8c067f8457efd85f0f3bd240b 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-22  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/32563
+       * g++.dg/torture/pr32563.C: New testcase.
+
 2007-08-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/32912
diff --git a/gcc/testsuite/g++.dg/torture/pr32563.C b/gcc/testsuite/g++.dg/torture/pr32563.C
new file mode 100644 (file)
index 0000000..d536b3f
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+struct A
+{
+  char c[1];
+} a;
+
+const __SIZE_TYPE__ i = (__SIZE_TYPE__)&a.c[0] - 1;
index ce4ee5d263f0a314bb8ef271575ed62d04c64ffd..95aa1b9e040516dd9b900b931c7c0720f3d3630f 100644 (file)
@@ -4936,7 +4936,8 @@ host_integerp (const_tree t, int pos)
               && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) >= 0)
              || (! pos && TREE_INT_CST_HIGH (t) == -1
                  && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0
-                 && !TYPE_UNSIGNED (TREE_TYPE (t)))
+                 && (!TYPE_UNSIGNED (TREE_TYPE (t))
+                     || TYPE_IS_SIZETYPE (TREE_TYPE (t))))
              || (pos && TREE_INT_CST_HIGH (t) == 0)));
 }