https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108499
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Adding: if (!theSize) __builtin_unreachable(); After the declaration of theSize, fixes the warning. I don't know if in the original code there was a check for zero theSize or not but the warning disappears if there is. There is no way to figure out for the compiler that theSize is not zero either.