https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102238
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Martin Sebor from comment #2) > The source and the destination arrays in the test case do not overlap so > there is no warning. The preprocessed output makes it easier to see than > the original (the destination of the call is the a member of the object > pointed to by the function argument s3 and the %s argument the local array > 'a'): Silly mistake on my part, it is still buggy: /* { dg-do compile } { dg-options "-O2 -Wno-format-overflow -Wrestrict -ftrack-macro-expansion=0" } */ void sink (int); #define S10 "0123456789" extern char a2[2][22]; #define T(d, ...) do { \ char a[tttttttt22] = S10; \ sink (__builtin_sprintf ((d), __VA_ARGS__)); \ } while (0) struct S { char a[4]; char b[4]; }; struct S2 { struct S s_1; struct S s_2; struct S sa3[3]; }; struct S3 { struct S2 s2_1; struct S2 s2_2; struct { struct { struct { struct S sa_3[3]; } a_1[3]; } a_2[3][3]; } a_3[3][3][3]; char fa[]; }; void test_struct_member_array (struct S3 *s3, int i) { char *a1 = (char*)s3; char *d; const char *s; d = s3->s2_2.s_1.a; s = s3->s2_2.s_1.a; T (d, "%s", a1 + 40); /* { dg-warning "overlaps" } */ T (d, "%s", a1 + 41); /* { dg-warning "may overlap" } */ T (d, "%s", a1 + 42); /* { dg-warning "may overlap" } */ }