http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50460
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-09-26
09:08:36 UTC ---
#define strcpy(x,y) __builtin___strcpy_chk (x, y, __builtin_object_size (x, 1))
int
f1 (void)
{
struct A { char buf1[9]; char buf2[4]; } a;
strcpy (a.buf1 + 9, "a");
return 0;
}
int
f2 (void)
{
struct A { char buf1[9]; char buf2[4]; } a;
strcpy (a.buf2 + 0, "a");
return 0;
}
int
f3 (void)
{
struct A { char buf1[9]; char buf2[4]; } a;
strcpy (a.buf1 + 10, "a");
return 0;
}
int
f4 (void)
{
struct A { char buf1[9]; char buf2[4]; } a;
strcpy (a.buf2 - 1, "a");
return 0;
}
int
f5 (void)
{
struct A { char buf1[9]; char buf2[4]; } a;
strcpy ((char *) &a + 10, "a");
return 0;
}
int
f6 (void)
{
struct A { char buf1[9]; char buf2[4]; } a;
strcpy ((char *) a.buf2 - 1, "a");
return 0;
}
used to warn in f{1,3,4,6} (and fail at runtime) and not in f{2,5} in
4.{1,2,3,4,6} (haven't checked 4.5), doesn't warn nor fail on the trunk.
So yes, 4.0+ clearly did some reconstruction, but only in limited cases (e.g.
when the &a is offsetted). Some field + offset remained COMPONENT_REF +
offset.