Since a1561c3bbe8e72c6e44280d1eb5e529d2da4ecd0, pthread_setspecific started to reject pseudo pointers like (const void *)1L:
printf.c:732:9: error: 'pthread_setspecific' expecting 1 byte in a region of size 0 [-Werror=stringop-overread]
732 | pthread_setspecific(cleanup_key, (const void *)1);
This breaks existing code that wants to signal special conditions to key readers ("not an object") or want to use pthread_key_create to register a per-thread destructor. These issues can be worked around, but users will be confronted with valid but no longer compiling code first of all.
Reading the Open Group spec on this, I do not find any hint that suggests only NULL or valid pointers must be passed to pthread_setspecific.
I'm not aware of any reasonable way to suppress this GCC warning.
Just to be clear, I agree that this warning is wrong because it also happens for MAP_FAILED and other POSIX pointer constants.
Then, could someone familiar with the details (also) file a bug report with them? Or did this happen already?
I found an existing GCC bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102329
It's not just pseudo-pointers, we get a warning for this as well:
extern int x;
f (pthread_key_t key)
pthread_setspecific (key, &x);