summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-12-02 17:14:18 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2008-12-02 17:14:18 +0000
commitf5fec377965fb10837ee39ee309b1c1551c65f11 (patch)
tree39bbecf80e9d1c5b798a7278196759f5812197f4
parent0ecf7a657255369b2827f6c14cf92c21b3c4e2f1 (diff)
downloadgcc-f5fec377965fb10837ee39ee309b1c1551c65f11.tar.gz
PR middle-end/38343
* builtins.c (fold_builtin_memory_op): Convert len to sizetype before using it in POINTER_PLUS_EXPR. * gcc.c-torture/compile/pr38343-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142363 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/builtins.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr38343-2.c12
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 843b22168bd..a0a839c4ab9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/38343
+ * builtins.c (fold_builtin_memory_op): Convert len to sizetype
+ before using it in POINTER_PLUS_EXPR.
+
2008-12-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38359
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 34066675873..444baa606d1 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8993,6 +8993,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i
len = fold_build2 (MINUS_EXPR, TREE_TYPE (len), len,
ssize_int (1));
+ len = fold_convert (sizetype, len);
dest = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len);
dest = fold_convert (type, dest);
if (expr)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 33d0f8650d9..a08d83b5b33 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/38343
+ * gcc.c-torture/compile/pr38343-2.c: New test.
+
2008-12-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38359
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38343-2.c b/gcc/testsuite/gcc.c-torture/compile/pr38343-2.c
new file mode 100644
index 00000000000..8444cc78f06
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr38343-2.c
@@ -0,0 +1,12 @@
+/* PR middle-end/38343 */
+
+static struct S
+{
+ char f[6];
+} s[] = { {"01000"} };
+
+char *
+foo (void)
+{
+ return __builtin_stpcpy (s[0].f, "S0022");
+}