https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71224
--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
And thinking more about it, I don't think it even explains why this triggers
the warning:
---
if (nlength < pthis->length)
{
Array aggr = {pthis->length - nlength, pthis->ptr + nlength};
for (size_t key = 0; key < aggr.length; key++)
aggr.ptr[key] = 0;
}
---
But this works just fine.
---
if (nlength < pthis->length)
{
if (pthis->length >= nlength)
__builtin_unreachable();
Array aggr = {pthis->length - nlength, pthis->ptr + nlength};
for (size_t key = 0; key < aggr.length; key++)
aggr.ptr[key] = 0;
}
---
Surely the optimizer must be able to deduce that if the first condition is
true, then the second condition must always be a given?