public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/106906] New: libgomp/env.c: 3 * boolean value assigned to pointer
@ 2022-09-12 11:01 dcb314 at hotmail dot com
2022-09-12 11:33 ` [Bug libgomp/106906] " jakub at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: dcb314 at hotmail dot com @ 2022-09-12 11:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106906
Bug ID: 106906
Summary: libgomp/env.c: 3 * boolean value assigned to pointer
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Static analyser cppcheck says:
libgomp/env.c:1895:19: error: Boolean value assigned to pointer.
[assignBoolToPointer]
libgomp/env.c:1902:19: error: Boolean value assigned to pointer.
[assignBoolToPointer]
libgomp/env.c:1910:19: error: Boolean value assigned to pointer.
[assignBoolToPointer]
First one is
icv_addr[1] = false;
but
void *icv_addr[3])
so this could probably benefit from a tidyup.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libgomp/106906] libgomp/env.c: 3 * boolean value assigned to pointer
2022-09-12 11:01 [Bug libgomp/106906] New: libgomp/env.c: 3 * boolean value assigned to pointer dcb314 at hotmail dot com
@ 2022-09-12 11:33 ` jakub at gcc dot gnu.org
2022-09-13 17:04 ` cvs-commit at gcc dot gnu.org
2022-09-13 17:06 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-09-12 11:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106906
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Well, it is correct as is, because while icv_addr[3] and params[3] have void *
type, they are actually cast to various types (either other pointers or bool
etc.).
But there is no need not to make the cast explicit and after all, there is
icv_addr[0] = icv_addr[1] = icv_addr[2] = NULL;
before the switch, so zero reinitialization is just a waste of time unless
compiler optimizes that out.
So we could go for:
2022-09-12 Jakub Jelinek <jakub@redhat.com>
PR libgomp/106906
* env.c (get_icv_member_addr): Cast false to void * before assigning
it to icv_addr[1], and comment the whole assignment out.
--- libgomp/env.c.jj 2022-09-12 10:32:00.935086858 +0200
+++ libgomp/env.c 2022-09-12 13:27:22.893571697 +0200
@@ -1892,14 +1892,14 @@ get_icv_member_addr (struct gomp_initial
{
case GOMP_ICV_NTEAMS:
icv_addr[0] = &icvs->nteams_var;
- icv_addr[1] = false;
+ /* icv_addr[1] = (void *) false; */
break;
case GOMP_ICV_DYNAMIC:
icv_addr[0] = &(*icvs).dyn_var;
break;
case GOMP_ICV_TEAMS_THREAD_LIMIT:
icv_addr[0] = &icvs->teams_thread_limit_var;
- icv_addr[1] = false;
+ /* icv_addr[1] = (void *) false; */
break;
case GOMP_ICV_SCHEDULE:
icv_addr[0] = &icvs->run_sched_var;
@@ -1907,7 +1907,7 @@ get_icv_member_addr (struct gomp_initial
break;
case GOMP_ICV_THREAD_LIMIT:
icv_addr[0] = &icvs->thread_limit_var;
- icv_addr[1] = false;
+ /* icv_addr[1] = (void *) false; */
icv_addr[2] = (void *) UINT_MAX;
break;
case GOMP_ICV_NTHREADS:
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libgomp/106906] libgomp/env.c: 3 * boolean value assigned to pointer
2022-09-12 11:01 [Bug libgomp/106906] New: libgomp/env.c: 3 * boolean value assigned to pointer dcb314 at hotmail dot com
2022-09-12 11:33 ` [Bug libgomp/106906] " jakub at gcc dot gnu.org
@ 2022-09-13 17:04 ` cvs-commit at gcc dot gnu.org
2022-09-13 17:06 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-13 17:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106906
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:e11babbfac21163118b69dd25b468ade80dbe8de
commit r13-2652-ge11babbfac21163118b69dd25b468ade80dbe8de
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Sep 13 19:00:02 2022 +0200
libgomp: Appease some static analyzers [PR106906]
While icv_addr[1] = false; assignments where icv_addr has void *
element type is correct and matches how it is used (in those cases
the void * pointer is then cast to bool and used that way), there is no
reason not to add explicit (void *) casts there which are there already
for (void *) true. And, there is in fact even no point in actually
doing those stores at all because we set that pointer to NULL a few
lines earlier. So, this patch adds the explicit casts and then
comments those out to show intent.
2022-09-13 Jakub Jelinek <jakub@redhat.com>
PR libgomp/106906
* env.c (get_icv_member_addr): Cast false to void * before
assigning
it to icv_addr[1], and comment the whole assignment out.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libgomp/106906] libgomp/env.c: 3 * boolean value assigned to pointer
2022-09-12 11:01 [Bug libgomp/106906] New: libgomp/env.c: 3 * boolean value assigned to pointer dcb314 at hotmail dot com
2022-09-12 11:33 ` [Bug libgomp/106906] " jakub at gcc dot gnu.org
2022-09-13 17:04 ` cvs-commit at gcc dot gnu.org
@ 2022-09-13 17:06 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-09-13 17:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106906
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tweaked (not saying fixed because there is no bug to fix).
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-13 17:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 11:01 [Bug libgomp/106906] New: libgomp/env.c: 3 * boolean value assigned to pointer dcb314 at hotmail dot com
2022-09-12 11:33 ` [Bug libgomp/106906] " jakub at gcc dot gnu.org
2022-09-13 17:04 ` cvs-commit at gcc dot gnu.org
2022-09-13 17:06 ` jakub at gcc dot gnu.org
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).