diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-04-09 10:18:47 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-04-09 10:18:47 +0200 |
commit | 8cc863ca8f48662e9c9339710fa303587479bf71 (patch) | |
tree | c757ad06ad7b39f149abde77a4b85920f085fa86 /libgomp | |
parent | 019a922063f26784d5a070d9198a1f937b8a8343 (diff) | |
download | gcc-8cc863ca8f48662e9c9339710fa303587479bf71.zip gcc-8cc863ca8f48662e9c9339710fa303587479bf71.tar.gz gcc-8cc863ca8f48662e9c9339710fa303587479bf71.tar.bz2 |
libgomp: Silence false positive -Wmaybe-uninitialized warning [PR99984]
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.
Anyway, in this case it is easy to workaround the warning by moving the
pthread_setspecific call after the initialization without slowing anything
down.
2021-04-09 Jakub Jelinek <jakub@redhat.com>
PR libgomp/99984
* team.c (gomp_thread_start): Call pthread_setspecific for
!(defined HAVE_TLS || defined USE_EMUTLS) only after local_thr
has been initialized to avoid false positive warning.
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/team.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libgomp/team.c b/libgomp/team.c index 9662234..ba57152 100644 --- a/libgomp/team.c +++ b/libgomp/team.c @@ -78,7 +78,6 @@ gomp_thread_start (void *xdata) #else struct gomp_thread local_thr; thr = &local_thr; - pthread_setspecific (gomp_tls_key, thr); #endif gomp_sem_init (&thr->release, 0); @@ -92,6 +91,9 @@ gomp_thread_start (void *xdata) #ifdef GOMP_NEEDS_THREAD_HANDLE thr->handle = data->handle; #endif +#if !(defined HAVE_TLS || defined USE_EMUTLS) + pthread_setspecific (gomp_tls_key, thr); +#endif thr->ts.team->ordered_release[thr->ts.team_id] = &thr->release; |