Hi! The PR50700 change caused infinite recursion - we shouldn't call compute_builtin_object_size on SSA_NAMEs more than two times, otherwise we risk calling it endlessly. But TREE_CODE (pt_var) in this code is known to be MEM_REF, so always != SSA_NAME.
Fixed thusly, committed as obvious to trunk/4.6 after bootstrap/regtest on x86_64-linux and i686-linux. 2011-11-10 Jakub Jelinek <ja...@redhat.com> PR middle-end/51077 * tree-object-size.c (addr_object_size): Check TREE_CODE of MEM_REF's operand rather than code of the MEM_REF itself. * gcc.c-torture/compile/pr51077.c: New test. --- gcc/tree-object-size.c.jj 2011-10-12 20:28:20.000000000 +0200 +++ gcc/tree-object-size.c 2011-11-10 11:53:37.106777916 +0100 @@ -175,7 +175,7 @@ addr_object_size (struct object_size_inf unsigned HOST_WIDE_INT sz; if (!osi || (object_size_type & 1) != 0 - || TREE_CODE (pt_var) != SSA_NAME) + || TREE_CODE (TREE_OPERAND (pt_var, 0)) != SSA_NAME) { sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0), object_size_type & ~1); --- gcc/testsuite/gcc.c-torture/compile/pr51077.c.jj 2011-11-10 12:05:24.797638658 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr51077.c 2011-11-10 12:04:59.000000000 +0100 @@ -0,0 +1,15 @@ +/* PR middle-end/51077 */ + +struct S { unsigned char s, t[256]; }; + +void +foo (const struct S *x, struct S *y, int z) +{ + int i; + for (i = 0; i < 8; i++) + { + const struct S *a = &x[i]; + __builtin___memcpy_chk (y->t, a->t, z, __builtin_object_size (y->t, 0)); + y = (struct S *) &y->t[z]; + } +} Jakub