re PR middle-end/38343 (ice for legal code with -O2)

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.

From-SVN: r142363
This commit is contained in:
Jakub Jelinek 2008-12-02 18:14:18 +01:00 committed by Jakub Jelinek
parent 09ce620eab
commit fe5c443ea5
4 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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");
}