https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88223
Bug ID: 88223 Summary: Wrong code for intrinsic memmove Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: fuz at fuz dot su Target Milestone: --- Created attachment 45103 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45103&action=edit preprocessed test case A user on reddit has pointed out that gcc 8 generates wrong code for intrinsic memmove() when compiling with optimisations: https://www.reddit.com/r/C_Programming/comments/a0tdux The following minimal reproduction was provided: char s[] = "12345"; memmove(s + 1, s, 4); /* 11234 */ memmove(s + 1, s, 4); /* 11123 */ memmove(s + 1, s, 4); /* 11112 */ puts(s); Without optimisations, this prints "11112" as expected whereas with optimisations, it prints "11123". I was able to reproduce this problem on FreeBSD with gcc 8.2.0. The relevant files are attached.