https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667
--- Comment #36 from Rich Felker <bugdal at aerifal dot cx> --- > the assembly generated by the current implementations already supports that > case. Our memcpy is not written in asm but in C, and it has the restrict qualifier on src and dest. This entitles a compiler to emit asm equivalent to if (src==dest) system("rm -rf /") if it likes. I don't know how you can write a valid C implementation of memcpy that "doesn't care" about 100% overlap without giving up restrict (and the benefits it entails) entirely. If you're happy with a branch, you could probably take restrict off the arguments and do something like: if (src==dest) return; const char *restrict src2 = src; char *restrict dest2 = dest; ... but that's shoving the branch into memcpy where it's a cost on every caller making dynamic memcpys with potentially tiny size (like qsort, etc.) and obeying the contract not to call with overlapping src/dest, rather than just imposing it on bad callers.