From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A7D233857C6C; Sun, 11 Oct 2020 17:01:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7D233857C6C 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: Sun, 11 Oct 2020 17:01:33 +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: 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: 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: Sun, 11 Oct 2020 17:01:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97370 Harald van Dijk changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #1 from Harald van Dijk --- > * 'f' is incorrectly diagnosed even though it's the same thing as 'i' aft= er commuting the operands of '&'. ('i' is correctly allowed.) When an expression is written as !a & b, it is possible the user intended != (a & b). If it is rewritten as b & !a, it is clear that the user did not intend = !(b & a). > * The diagnostic for 'f' suggests 'g', but 'g' produces the same diagnost= ic. Indeed, and that looks like a bad suggestion by GCC to me. The diagnostic f= or 'f' should be suggesting (!a) rather than !(a), which does manage to suppre= ss the diagnostic. > * The diagnostic for 'f' sugggests 'h', but 'h' produces a different diagnostic. Although in general, informing the user that they may have wanted to use ~ = may be useful, I personally think that suggestion should be dropped if the oper= and is of type _Bool/bool. You're correct that bool & ~bool will have the inten= ded result but my opinion is that that is overly clever code that hurts readability, and GCC should not be offering that as a suggestion.=