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]; } } ICEs at -O2 starting with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179850 (aka PR50700 fix). Yet untested fix: --- 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); TREE_CODE (pt_var) != SSA_NAME is always 1, because a few lines above this we check that TREE_CODE (pt_var) == MEM_REF.
Created attachment 25777 [details] gcc47-pr51077.patch Patch.
Ick ;) Quite obvious when it doesn't cause any fallout.
Author: jakub Date: Thu Nov 10 19:02:30 2011 New Revision: 181263 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181263 Log: 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. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr51077.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-object-size.c
Author: jakub Date: Thu Nov 10 19:04:01 2011 New Revision: 181264 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181264 Log: 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. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.c-torture/compile/pr51077.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/tree-object-size.c
Fixed.