https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103733
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- That is still not equivalent, I bet you meant return !__builtin_memcmp. Anyway, the reason we can optimize memcmp and can't optimize the loop that the defaulted operator== emits is that there is no guarantee that all the bytes can be safely accessed if there is a difference in the bytes before it. Say when a points to end of mmaped region with only 8 bytes mapped in it and similarly for b.