https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68201
Bug ID: 68201 Summary: alloc_size attribute and memory pools Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bugzi...@poradnik-webmastera.com Target Milestone: --- When memory pool is used to allocate fixed-size blocks, size of block is often stored in structure describing mempool. In such case it is not possible to tell gcc via alloc_size attribute how much memory is allocated in pool_alloc function. Please add new attribute or extend existing one to support this case too. You can also provide new build-in function __builtin_set_object_size(ptr, size) which would be used to handle all non-trivial cases. Example: struct MemPool { size_t block_size; }; void* pool_alloc(struct MemPool *pool) { void *ptr = get_block_from_pool(pool); __builtin_set_object_size(ptr, pool->block_size); // example return ptr; }