https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97370
Harald van Dijk <harald at gigawatt dot nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> --- > * 'f' is incorrectly diagnosed even though it's the same thing as 'i' after > 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 diagnostic. Indeed, and that looks like a bad suggestion by GCC to me. The diagnostic for 'f' should be suggesting (!a) rather than !(a), which does manage to suppress 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 operand is of type _Bool/bool. 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.