https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92380
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- The warning was introduced in r275981 which was an enhancement to detect more instances of inadvertent accesses past the end of struct members. It might be possible to relax the warning to handle some of these cases but I'm not convinced it's a good idea or worth the trouble for code that does these sorts of type-punning tricks. I suggest to rewrite the code in a more straightforward way and without the casts, e.g., like so: char *t1 (outer_struct *p, char str[240]) { char *q = (char*)p + sizeof *p - (sizeof(inner_large_struct) - sizeof(inner_small_struct)) + offsetof (flexarr_struct, s); __builtin_strcpy (q, str); return q; } When starting with a pointer to the the enclosing object GCC treats as valid accesses to the whole object if it's known (or to the largest array of such objects when it isn't). Otherwise, only accesses to the same member are considered valid when using a pointer derived from the address of that member.