https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503
--- Comment #6 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> --- So basically, __builtin_with_access(void *ptr, size_t size, int access) where access == -1: Unknown access semantics 0: none 1: read_only 2: write_only 3: read_write should address both access and alloc_size and even counted_by. We would need to emit the builtin in the caller as well as callee of the function that has the access attribute while for alloc_size, we only need to emit this in the caller.