public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/27714] New: pthread_setspecific missing attribute access none
@ 2021-04-09 16:26 msebor at gmail dot com
  2021-04-22 21:31 ` [Bug nptl/27714] " msebor at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: msebor at gmail dot com @ 2021-04-09 16:26 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 27714
           Summary: pthread_setspecific missing attribute access none
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: nptl
          Assignee: unassigned at sourceware dot org
          Reporter: msebor at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

GCC 11 has enhanced -Wmaybe-uninitialized to trigger when the address of an
uninitialized object is passed to a const pointer function parameter.  The
assumption is that the function will most likely read the referenced object. 
As a result, when compiled with GCC 11, code that passes such an address to
pthread_setspecific() such as the test case below triggers the warning.  This
has caused the following failure in GCC
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99984.

$ cat z.c && gcc -S -Wall z.c 
#include <pthread.h>

void f (pthread_key_t key)
{
  int x;
  pthread_setspecific (key, &x);
}
z.c: In function ‘f’:
z.c:6:3: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
    6 |   pthread_setspecific (key, &x);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from z.c:1:
/usr/include/pthread.h:1123:12: note: by argument 2 of type ‘const void *’ to
‘pthread_setspecific’ declared here
 1123 | extern int pthread_setspecific (pthread_key_t __key,
      |            ^~~~~~~~~~~~~~~~~~~
z.c:5:7: note: ‘x’ declared here
    5 |   int x;
      |       ^

(The same warning is triggered when the result of malloc() is passed to the
function.)

To avoid the warning in calls to functions like pthread_setspecific that don't
read the object GCC 11 also extends attribute access to accept a new mode:
none.  Glibc should make use of the attribute in the declaration of the
function (and any others like it).

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-28 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 16:26 [Bug nptl/27714] New: pthread_setspecific missing attribute access none msebor at gmail dot com
2021-04-22 21:31 ` [Bug nptl/27714] " msebor at gmail dot com
2021-04-27 19:10 ` msebor at gmail dot com
2021-04-28  1:29 ` hjl.tools at gmail dot com
2021-04-28 19:05 ` msebor at gmail dot com
2021-11-28 16:49 ` khuey at kylehuey dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).