https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106774
Bug ID: 106774 Summary: warning about comparison to true/false Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenb...@fh-soft.de Target Milestone: --- gcc has "-Wbool-compare" to warn about boolean expression compared with an integer value different from true/false. This warning is enabled by -Wall. However, a warning for comparisons with true and false may also be useful. The former is redundant, the latter can be replaced with "!". Actually, this warning may also be given when comparing a non-Boolean integral expression with true or false. The former is not redundant, but may often not be what's intended (if so, one should compare with 1). The latter is equivalent to comparing with 0, but still strange style. And comparing non-integral (e.g. floating-point) expressions with Boolean literals is certainly warning-worthy (though it may be caught by "-Wfloat-equal" as well). To sum up, a new warning about comparing any expression with true/false literals. Maybe something like "-Wbool-compare=2" (which would not be enabled by -Wall, I guess; maybe by -Wextra, but even if it must be given manually, I'd find it useful).