From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 18CB53858434; Thu, 11 May 2023 21:41:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18CB53858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683841313; bh=oRRq3QLMG22jKSzK8woHWG7yxStsBgpe4Zmuidrylf0=; h=From:To:Subject:Date:From; b=Aahc2a6AYm5gtM6iqRqettjeNiUDUPxj1/QuVS4zfsgJN9HevLCbqixjBh+H2dYK1 1cAb/hdm68eN5E4EnDEnYRq6dYIZGDB1oPfy3R7eUR0OZk+31jbggiiVfPvHUDwtSH i9HQLGu1gXdsugy04G23JmjD8W2OeSzmWyTeLJUA= From: "ansuelsmth at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109820] New: False-positive in tautological-compare Date: Thu, 11 May 2023 21:41:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ansuelsmth at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109820 Bug ID: 109820 Summary: False-positive in tautological-compare Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ansuelsmth at gmail dot com Target Milestone: --- Created attachment 55058 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55058&action=3Dedit preprocessed file Hi, while having fun with fixing some compilation warning to enforce WERROR= on kernel linux I faced this interesting false-positive warning. The simple repro code is this #include #include #include #include int main() { uint32_t test; if (((test >> 4) & 0x15) =3D=3D 0x9) return 1; return 0; } Compiled with gcc -o test test.c -Wall -Werror Result in warning test.c: In function =E2=80=98main=E2=80=99: test.c:10:34: error: bitwise comparison always evaluates to false [-Werror=3Dtautological-compare] 10 | if (((test >> 4) & 0x15) =3D=3D 0x9) | ^~ cc1: all warnings being treated as errors Decreasing the 0x9 to something like 0x5 mute the warning. It's either a false positive or a warning that gets not triggered in some corner case. I have attached the .i as asked in the guidelines. Don't know if -v is need= ed. This is simple gcc installed from ubuntu devel I also verified that this is present in gcc 13.1=