https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97370

--- Comment #2 from eggert at cs dot ucla.edu ---
(In reply to Harald van Dijk from comment #1)

> When an expression is written as !a & b, it is possible the user intended
> !(a & b).

That's so unlikely as to not be worth worrying about. And even if it were more
likely, the same argument would apply to !a && b. Surely you're not suggesting
-Wparentheses should diagnose !a && b (that would generate many false alarms),
so -Wparentheses shouldn't diagnose !a & b either.

> You're correct that bool & ~bool will have
> the intended result but my opinion is that that is overly clever code that
> hurts readability, and GCC should not be offering that as a suggestion.

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. -Wbool-operation is
intended to diagnose likely bugs, not to diagnose "bad" style.

Reply via email to