https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94444
--- Comment #4 from felix-gcc at fefe dot de --- Sure, here's a test case: #include <stddef.h> __attribute__((access(read_only,2,3), access(write_only,1,3))) extern void* memcpy(void* dest, const void* src, size_t len); int main() { char buf[10]; memcpy(buf,"fnordfnord",11); // should reject or at least warn } $ gcc -c t.c t.c: In function ‘main’: t.c:8:3: warning: ‘memcpy’ writing 11 bytes into a region of size 10 overflows the destination [-Wstringop-overflow=] 8 | memcpy(buf,"fnordfnord",11); // should reject or at least warn | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ t.c:4:14: note: in a call to function ‘memcpy’ declared with attribute ‘write_only (1, 3)’ 4 | extern void* memcpy(void* dest, const void* src, size_t len); | ^~~~~~ $ gcc -c t.c -Os $ gcc -v [...] gcc version 10.0.1 20200401 (experimental) (GCC)