public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99588] variable set but not used warning on static _Atomic assignment Date: Thu, 18 Mar 2021 11:29:52 +0000 [thread overview] Message-ID: <bug-99588-4-5dpbt3Y0cI@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99588-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99588 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- More complete testcase: void bar (int, ...); void f1 (void) { static _Atomic int x = 0; bar (0, x); } void f2 (void) { static _Atomic int x = 0; bar (0, x += 1); } void f3 (void) { static _Atomic int x = 0; bar (x); } void f4 (void) { static _Atomic int x = 0; bar (x += 1); } void f5 (void) { static _Atomic int x = 0; bar (x = 1); } void f6 (void) { static _Atomic int x = 0; x = 1; } void f7 (void) { static _Atomic int x = 0; x += 3; } void f8 (void) { _Atomic int x = 0; bar (0, x); } void f9 (void) { _Atomic int x = 0; bar (0, x += 1); } void f10 (void) { _Atomic int x = 0; bar (x); } void f11 (void) { _Atomic int x = 0; bar (x += 1); } void f12 (void) { _Atomic int x = 0; bar (x = 1); } void f13 (void) { _Atomic int x = 0; x = 1; } void f14 (void) { _Atomic int x = 0; x += 3; } With -D_Atomic= we warn on f6 and f13 and nothing else, otherwise on everything but f1, f3, f8, f10. The reason for not warning on the f{1,3,8,10} is convert_lvalue_to_rvalue: /* EXPR is always read. */ mark_exp_read (exp.value); So for consistency with the non-_Atomic x op= expr at least should mark_exp_read too in build_atomic_assign (i.e. something like: if (modifycode != NOP_EXPR) mark_exp_read (lhs); somewhere early. That results in warning on f{5,6,12,13}, f5 and f12 still being false positives.
next prev parent reply other threads:[~2021-03-18 11:29 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-15 1:53 [Bug c/99588] New: " godmar at gmail dot com 2021-03-15 8:55 ` [Bug c/99588] " rguenth at gcc dot gnu.org 2021-03-16 20:28 ` egallager at gcc dot gnu.org 2021-03-18 11:29 ` jakub at gcc dot gnu.org [this message] 2021-03-18 13:14 ` jakub at gcc dot gnu.org 2021-03-19 21:55 ` cvs-commit at gcc dot gnu.org 2021-03-19 21:56 ` jakub at gcc dot gnu.org 2021-03-30 22:41 ` cvs-commit at gcc dot gnu.org 2021-03-31 6:46 ` jakub at gcc dot gnu.org 2021-04-20 23:33 ` cvs-commit at gcc dot gnu.org 2021-04-22 16:51 ` cvs-commit at gcc dot gnu.org 2021-04-22 17:11 ` jakub at gcc dot gnu.org 2021-09-11 14:24 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99588-4-5dpbt3Y0cI@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).