https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104069
--- Comment #14 from Martin Sebor <msebor at gcc dot gnu.org> --- Removing the test for !size from the first conditional avoids the warning. I don't fully understand what the code tries to do but the following avoids it at -O2 (only): void *xrealloc (void *ptr, int size) { if (!size) size = 1; void *ret = __builtin_realloc (ptr, size); if (!ret) ret = __builtin_realloc (ptr, 1); if (!ret) { ret = __builtin_realloc (ptr, size); if (!ret) ret = __builtin_realloc(ptr, 1); if (!ret) __builtin_abort (); } return ret; }