[Bug c/80378] Extend alloc_size attribute for better Linux kernel checking

andi-gcc at firstfloor dot org gcc-bugzilla@gcc.gnu.org
Mon Apr 24 15:05:00 GMT 2017


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);


More information about the Gcc-bugs mailing list