https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67618
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> --- Why do you call it wrong? It is always legal to replace malloc with calloc, and if we do it, the memset becomes useless. It may not be optimal from a performance POV, but I don't see where it breaks anything. As for the infinite loop, that's a know problem not specific to this function and there are already several PRs/emails about it. When you compile the C library itself, you are supposed to pass some options to gcc so it knows not to do that.