This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/80378] Extend alloc_size attribute for better Linux kernel checking
- From: "andi-gcc at firstfloor dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 24 Apr 2017 15:05:48 +0000
- Subject: [Bug c/80378] Extend alloc_size attribute for better Linux kernel checking
- Auto-submitted: auto-generated
- References: <bug-80378-4@http.gcc.gnu.org/bugzilla/>
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);