https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117279
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Created attachment 59427 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59427&action=edit reduced testcase The problem is once we assign p.ptr to p.local_buf, GCC thinks the whole of p escapes except p itself never escapes out of the function not even via p.ptr.