From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8DE413851C0B; Mon, 12 Oct 2020 18:16:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DE413851C0B From: "harald at gigawatt dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/97370] comedy of boolean errors for '!a & (b|c)' Date: Mon, 12 Oct 2020 18:16:08 +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: 10.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: harald at gigawatt dot nl 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: 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: Mon, 12 Oct 2020 18:16:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97370 --- Comment #3 from Harald van Dijk --- (In reply to eggert from comment #2) > That's so unlikely as to not be worth worrying about. See PR 7543 for the history of that warning. > And even if it were > more likely, the same argument would apply to !a && b. A very significant difference is that !a && b is commonly seen where it is exactly what the programmer wanted. For !a & b, that is not generally the c= ase. Perhaps the warning could be suppressed specifically for boolean variables, since those make it more likely that the (!a) & b meaning is exactly what is intended? > The GCC documentation says the motivation for warning about ~bool is that > it's very likely a bug in the program. This motivation does not apply to > bool & ~bool, so it'd be better to not warn for that case. Agreed. Apologies for the confusion there, I was trying to say I think the suggestion to use ~ should be dropped, in which case the warning generated = for the ~ form becomes unrelated to your issue. I was not trying to say that the warning generated for the ~ form should be kept.=