https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101751
Florian Weimer <fw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fw at gcc dot gnu.org --- Comment #1 from Florian Weimer <fw at gcc dot gnu.org> --- Martin and I discussed this before. I believe the use of attribute access with pthread_setspecific is quite wrong because it does not dereference the pointer at all. Consider this example: #include <pthread.h> #include <sys/mman.h> void f (pthread_key_t key) { pthread_setspecific (key, MAP_FAILED); } There is no way POSIX would consider this code invalid, but yet we warn: t.c: In function ‘f’: t.c:7:3: warning: ‘pthread_setspecific’ expecting 1 byte in a region of size 0 [-Wstringop-overread] 7 | pthread_setspecific (key, MAP_FAILED); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from t.c:1: /usr/include/pthread.h:1308:12: note: in a call to function ‘pthread_setspecific’ declared with attribute ‘access (none, 2)’ 1308 | extern int pthread_setspecific (pthread_key_t __key, | ^~~~~~~~~~~~~~~~~~~ Removing attribute access is not a solution because the warning is implied by the const void * argument type already. Access type none is merely declaration that the pointed-to memory need not be initialized, it still needs to be a valid address. So yes, I consider this a GCC diagnostics bug: not for access type none, but the fact that the diagnostic cannot be disabled at all for functions like pthread_setspecific.