https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91397
--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> --- if (g == 0) return (char *)malloc(0); for (;;) ; so the only way this can return is if g is 0. This means that in j, k is -1, and you are calling memcpy with a huge argument. So at least in the reduced testcase, the warning makes some sense.