On 4/9/21 10:30 AM, Jakub Jelinek wrote:
On Fri, Apr 09, 2021 at 10:28:47AM -0600, Martin Sebor wrote:
pthread_setspecific second argument is const void *, so that one can
call it even with pointers to const, but the function only stores the
pointer and does nothing else, so the new assumption of -Wmaybe-uninitialized
that functions taking such pointers will read from what those pointers
will point to is wrong.  Maybe it would be useful to have some whitelist
of functions that surely don't do that.

The intended mechanism to suppress the warning in these cases is
attribute access:  adding __attribute__ ((access (none, 2))) to
pthread_setspecific() avoids the warning.  I opened a Glibc bug
to do that:

   https://sourceware.org/bugzilla/show_bug.cgi?id=27714

While that is nice, the bugreport wasn't about glibc (where one has TLS and
so doesn't run into it), but uclibc.

The same applies there, as well as to any other code base that
declares such functions (e.g., the Linux kernel for which
the attribute was added).

(Otherwise, to add pthread_setspecific to the "white list" is
to add a built-in with the attribute for it.)

Martin

Reply via email to