https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117322
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So adding: if ((long)(len*4) <= 0) return; Fixes the warning. Looks like GCC does not realize len can't be too big to overflow. I am not 100% sure if the warning should be better worded or there is a missed optimization here.