From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3E3853850432; Thu, 18 Mar 2021 11:29:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E3853850432 From: "jakub at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2021 11:29:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99588 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- More complete testcase: void bar (int, ...); void f1 (void) { static _Atomic int x =3D 0; bar (0, x); } void f2 (void) { static _Atomic int x =3D 0; bar (0, x +=3D 1); } void f3 (void) { static _Atomic int x =3D 0; bar (x); } void f4 (void) { static _Atomic int x =3D 0; bar (x +=3D 1); } void f5 (void) { static _Atomic int x =3D 0; bar (x =3D 1); } void f6 (void) { static _Atomic int x =3D 0; x =3D 1; } void f7 (void) { static _Atomic int x =3D 0; x +=3D 3; } void f8 (void) { _Atomic int x =3D 0; bar (0, x); } void f9 (void) { _Atomic int x =3D 0; bar (0, x +=3D 1); } void f10 (void) { _Atomic int x =3D 0; bar (x); } void f11 (void) { _Atomic int x =3D 0; bar (x +=3D 1); } void f12 (void) { _Atomic int x =3D 0; bar (x =3D 1); } void f13 (void) { _Atomic int x =3D 0; x =3D 1; } void f14 (void) { _Atomic int x =3D 0; x +=3D 3; } With -D_Atomic=3D 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=3D expr at least should mark_exp_read too in build_atomic_assign (i.e. something like: if (modifycode !=3D 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.=