https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69172
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 37246 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37246&action=edit gcc6-pr69172.patch Untested fix. That said, the testcase is undefined behavior at runtime (both because the src and dest of mempcpy overlap and because (but that might be just in the reduced testcase) the last argument to __mempcpy_chk is 0, which indicates no bytes can be copied).