https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80378
--- Comment #6 from Andi Kleen <andi-gcc at firstfloor dot org> --- In the kernel there is also an upper limit on allocations. Perhaps just a generic assert builtin that: - uses value range information - uses constant propagation - is a nop when the compiler doesn't have either of this available - otherwise warns at build time __builtin_compile_assert(size >= 0 && size < MAX_ALLOC_SIZE);